github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/website/source/docs/providers/aws/r/codepipeline.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_codepipeline" 4 sidebar_current: "docs-aws-resource-codepipeline" 5 description: |- 6 Provides a CodePipeline 7 --- 8 9 # aws\_codepipeline 10 11 Provides a CodePipeline. 12 13 ~> **NOTE on `aws_codepipeline`:** - the `GITHUB_TOKEN` environment variable must be set if the GitHub provider is specified. 14 15 ## Example Usage 16 17 ```hcl 18 resource "aws_s3_bucket" "foo" { 19 bucket = "test-bucket" 20 acl = "private" 21 } 22 23 resource "aws_iam_role" "foo" { 24 name = "test-role" 25 26 assume_role_policy = <<EOF 27 { 28 "Version": "2012-10-17", 29 "Statement": [ 30 { 31 "Effect": "Allow", 32 "Principal": { 33 "Service": "codepipeline.amazonaws.com" 34 }, 35 "Action": "sts:AssumeRole" 36 } 37 ] 38 } 39 EOF 40 } 41 42 resource "aws_iam_role_policy" "codepipeline_policy" { 43 name = "codepipeline_policy" 44 role = "${aws_iam_role.codepipeline_role.id}" 45 policy = <<EOF 46 { 47 "Version": "2012-10-17", 48 "Statement": [ 49 { 50 "Effect":"Allow", 51 "Action": [ 52 "s3:GetObject", 53 "s3:GetObjectVersion", 54 "s3:GetBucketVersioning" 55 ], 56 "Resource": [ 57 "${aws_s3_bucket.foo.arn}", 58 "${aws_s3_bucket.foo.arn}/*" 59 ] 60 }, 61 { 62 "Effect": "Allow", 63 "Action": [ 64 "codebuild:BatchGetBuilds", 65 "codebuild:StartBuild" 66 ], 67 "Resource": "*" 68 } 69 ] 70 } 71 EOF 72 } 73 74 resource "aws_codepipeline" "foo" { 75 name = "tf-test-pipeline" 76 role_arn = "${aws_iam_role.foo.arn}" 77 78 artifact_store { 79 location = "${aws_s3_bucket.foo.bucket}" 80 type = "S3" 81 } 82 83 stage { 84 name = "Source" 85 86 action { 87 name = "Source" 88 category = "Source" 89 owner = "ThirdParty" 90 provider = "GitHub" 91 version = "1" 92 output_artifacts = ["test"] 93 94 configuration { 95 Owner = "my-organization" 96 Repo = "test" 97 Branch = "master" 98 } 99 } 100 } 101 102 stage { 103 name = "Build" 104 105 action { 106 name = "Build" 107 category = "Build" 108 owner = "AWS" 109 provider = "CodeBuild" 110 input_artifacts = ["test"] 111 version = "1" 112 113 configuration { 114 ProjectName = "test" 115 } 116 } 117 } 118 } 119 ``` 120 121 ## Argument Reference 122 123 The following arguments are supported: 124 125 * `name` - (Required) The name of the pipeline. 126 * `role_arn` - (Required) A service role Amazon Resource Name (ARN) that grants AWS CodePipeline permission to make calls to AWS services on your behalf. 127 * `artifact_store` (Required) An artifact_store block. Artifact stores are documented below. 128 * `stage` (Required) A stage block. Stages are documented below. 129 130 131 An `artifact_store` block supports the following arguments: 132 133 * `location` - (Required) The location where AWS CodePipeline stores artifacts for a pipeline, such as an S3 bucket. 134 * `type` - (Required) The type of the artifact store, such as Amazon S3 135 * `encryption_key` - (Optional) The encryption key AWS CodePipeline uses to encrypt the data in the artifact store, such as an AWS Key Management Service (AWS KMS) key. If you don't specify a key, AWS CodePipeline uses the default key for Amazon Simple Storage Service (Amazon S3). 136 137 138 A `stage` block supports the following arguments: 139 140 * `name` - (Required) The name of the stage. 141 * `action` - (Required) The action(s) to include in the stage 142 143 ## Attributes Reference 144 145 The following attributes are exported: 146 147 * `id` - The codepipeline ID. 148 149 ## Import 150 151 CodePipelines can be imported using the name, e.g. 152 153 ``` 154 $ terraform import aws_codepipeline.foo example 155 ```