Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add execution_mode arg to aws_codepipeline #35875

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/35875.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_codepipeline: Add `execution_mode` attribute
```
12 changes: 11 additions & 1 deletion internal/service/codepipeline/codepipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func resourcePipeline() *schema.Resource {
"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"type": {
Type: schema.TypeString,
Expand All @@ -95,6 +94,12 @@ func resourcePipeline() *schema.Resource {
},
},
},
"execution_mode": {
Type: schema.TypeString,
Optional: true,
Default: types.ExecutionModeSuperseded,
ValidateDiagFunc: enum.Validate[types.ExecutionMode](),
},
"name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -302,6 +307,7 @@ func resourcePipelineRead(ctx context.Context, d *schema.ResourceData, meta inte
return sdkdiag.AppendErrorf(diags, "setting artifact_store: %s", err)
}
}
d.Set("execution_mode", pipeline.ExecutionMode)
d.Set("name", pipeline.Name)
d.Set("pipeline_type", pipeline.PipelineType)
d.Set("role_arn", pipeline.RoleArn)
Expand Down Expand Up @@ -460,6 +466,10 @@ func expandPipelineDeclaration(d *schema.ResourceData) (*types.PipelineDeclarati
}
}

if v, ok := d.GetOk("execution_mode"); ok {
apiObject.ExecutionMode = types.ExecutionMode(v.(string))
}

if v, ok := d.GetOk("name"); ok {
apiObject.Name = aws.String(v.(string))
}
Expand Down
9 changes: 9 additions & 0 deletions internal/service/codepipeline/codepipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ func TestAccCodePipeline_MultiRegion_convertSingleRegion(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckPipelineExists(ctx, resourceName, &p),
resource.TestCheckResourceAttr(resourceName, "artifact_store.#", "1"),
resource.TestCheckResourceAttr(resourceName, "artifact_store.0.region", ""),
resource.TestCheckResourceAttr(resourceName, "stage.1.name", "Build"),
resource.TestCheckResourceAttr(resourceName, "stage.1.action.#", "1"),
resource.TestCheckResourceAttr(resourceName, "stage.1.action.0.name", "Build"),
Expand All @@ -408,6 +409,8 @@ func TestAccCodePipeline_MultiRegion_convertSingleRegion(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckPipelineExists(ctx, resourceName, &p),
resource.TestCheckResourceAttr(resourceName, "artifact_store.#", "2"),
resource.TestCheckResourceAttr(resourceName, "artifact_store.0.region", acctest.Region()),
resource.TestCheckResourceAttr(resourceName, "artifact_store.1.region", acctest.AlternateRegion()),
resource.TestCheckResourceAttr(resourceName, "stage.1.name", "Build"),
resource.TestCheckResourceAttr(resourceName, "stage.1.action.#", "2"),
resource.TestCheckResourceAttr(resourceName, "stage.1.action.0.name", "Build"),
Expand All @@ -421,6 +424,7 @@ func TestAccCodePipeline_MultiRegion_convertSingleRegion(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckPipelineExists(ctx, resourceName, &p),
resource.TestCheckResourceAttr(resourceName, "artifact_store.#", "1"),
resource.TestCheckResourceAttr(resourceName, "artifact_store.0.region", ""),
resource.TestCheckResourceAttr(resourceName, "stage.1.name", "Build"),
resource.TestCheckResourceAttr(resourceName, "stage.1.action.#", "1"),
resource.TestCheckResourceAttr(resourceName, "stage.1.action.0.name", "Build"),
Expand Down Expand Up @@ -615,6 +619,7 @@ func TestAccCodePipeline_pipelinetype(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "role_arn", "aws_iam_role.codepipeline_role", "arn"),
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "codepipeline", regexache.MustCompile(fmt.Sprintf("test-pipeline-%s", rName))),
resource.TestCheckResourceAttr(resourceName, "artifact_store.#", "1"),
resource.TestCheckResourceAttr(resourceName, "execution_mode", string(types.ExecutionModeSuperseded)),
resource.TestCheckResourceAttr(resourceName, "pipeline_type", string(types.PipelineTypeV1)),
resource.TestCheckResourceAttr(resourceName, "stage.#", "2"),
resource.TestCheckResourceAttr(resourceName, "stage.0.name", "Source"),
Expand Down Expand Up @@ -660,6 +665,7 @@ func TestAccCodePipeline_pipelinetype(t *testing.T) {
Config: testAccCodePipelineConfig_pipelinetypeUpdated(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckPipelineExists(ctx, resourceName, &p),
resource.TestCheckResourceAttr(resourceName, "execution_mode", string(types.ExecutionModeQueued)),
resource.TestCheckResourceAttr(resourceName, "pipeline_type", string(types.PipelineTypeV2)),
resource.TestCheckResourceAttr(resourceName, "stage.#", "2"),
resource.TestCheckResourceAttr(resourceName, "stage.0.name", "Source"),
Expand Down Expand Up @@ -704,6 +710,7 @@ func TestAccCodePipeline_pipelinetype(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "role_arn", "aws_iam_role.codepipeline_role", "arn"),
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "codepipeline", regexache.MustCompile(fmt.Sprintf("test-pipeline-%s", rName))),
resource.TestCheckResourceAttr(resourceName, "artifact_store.#", "1"),
resource.TestCheckResourceAttr(resourceName, "execution_mode", string(types.ExecutionModeSuperseded)),
resource.TestCheckResourceAttr(resourceName, "pipeline_type", string(types.PipelineTypeV1)),
resource.TestCheckResourceAttr(resourceName, "stage.#", "2"),
resource.TestCheckResourceAttr(resourceName, "stage.0.name", "Source"),
Expand Down Expand Up @@ -1187,6 +1194,8 @@ resource "aws_codepipeline" "test" {
}
}

execution_mode = "QUEUED"

pipeline_type = "V2"

variable {
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/codepipeline.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ This resource supports the following arguments:
* `pipeline_type` - (Optional) Type of the pipeline. Possible values are: `V1` and `V2`. Default value is `V1`.
* `role_arn` - (Required) A service role Amazon Resource Name (ARN) that grants AWS CodePipeline permission to make calls to AWS services on your behalf.
* `artifact_store` (Required) One or more artifact_store blocks. Artifact stores are documented below.
* `execution_mode` (Optional) The method that the pipeline will use to handle multiple executions. The default mode is `SUPERSEDED`. For value values, refer to the [AWS documentation](https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PipelineDeclaration.html#CodePipeline-Type-PipelineDeclaration-executionMode).

**Note:** `QUEUED` or `PARALLEL` mode can only be used with V2 pipelines.
* `stage` (Minimum of at least two `stage` blocks is required) A stage block. Stages are documented below.
* `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `variable` - (Optional) A pipeline-level variable block. Valid only when `pipeline_type` is `V2`. Variable are documented below.
Expand Down