github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/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. Defined as an `action` block below 142 143 A `action` block supports the following arguments: 144 145 * `category` - (Required) A category defines what kind of action can be taken in the stage, and constrains the provider type for the action. Possible values are `Approval`, `Build`, `Deploy`, `Invoke`, `Source` and `Test`. 146 * `owner` - (Required) The creator of the action being called. Possible values are `AWS`, `Custom` and `ThirdParty`. 147 * `name` - (Required) The action declaration's name. 148 * `provider` - (Required) The provider of the service being called by the action. Valid providers are determined by the action category. For example, an action in the Deploy category type might have a provider of AWS CodeDeploy, which would be specified as CodeDeploy. 149 * `version` - (Required) A string that identifies the action type. 150 * `configuration` - (Optional) A Map of the action declaration's configuration. 151 * `input_artifacts` - (Optional) A list of artifact names to be worked on. 152 * `output_artifacts` - (Optional) A list of artifact names to output. Output artifact names must be unique within a pipeline. 153 * `role_arn` - (Optional) The ARN of the IAM service role that will perform the declared action. This is assumed through the roleArn for the pipeline. 154 * `run_order` - (Optional) The order in which actions are run. 155 156 ~> **Note:** The input artifact of an action must exactly match the output artifact declared in a preceding action, but the input artifact does not have to be the next action in strict sequence from the action that provided the output artifact. Actions in parallel can declare different output artifacts, which are in turn consumed by different following actions. 157 158 ## Attributes Reference 159 160 The following attributes are exported: 161 162 * `id` - The codepipeline ID. 163 164 ## Import 165 166 CodePipelines can be imported using the name, e.g. 167 168 ``` 169 $ terraform import aws_codepipeline.foo example 170 ```