Skip to content

Commit

Permalink
feat: Add execution_mode arg to aws_codepipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
acwwat committed Feb 18, 2024
1 parent cb64b2a commit 354c1c0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
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
```
11 changes: 11 additions & 0 deletions internal/service/codepipeline/codepipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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 +308,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 +467,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
5 changes: 5 additions & 0 deletions internal/service/codepipeline/codepipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,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 +661,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 +706,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 +1190,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

0 comments on commit 354c1c0

Please sign in to comment.