terraform-provider-aws
terraform-provider-aws copied to clipboard
fix: update validation for image builder workflow type
Description
The documentation of the resource ami_imagebuilder_workflow
mentions for the argument type
Valid values: BUILD, TEST, DISTRIBUTION.
Image Builder handles the workflow type DISTRIBUTION, it cannot be configured by users. When trying to do so, for example using the code snippet provided as part of #39785
resource aws_imagebuilder_workflow codebuild-projects {
name = "CodeBuildProjectsDistributionWorkflow"
version = "1.0.0"
type = "DISTRIBUTION"
data = file("${path.module}/codebuild-projects-distribution.workflow.yaml")
}
the API returns the error The value supplied for parameter 'type' is not valid. Custom distribution workflows are not supported.
This pull request is to update the documentation for the resource as well as the validation for the argument. Two points from my side:
- For the validation I was not sure on the correct approach: I changed
ValidateDiagFunc
toValidateFunc
, typically it should be the other, right? Feedback is appreciated. - How would I test the change in the validation? At the moment we do not have a test for attribute
type
, but adding one would also not cover the change.
Relations
Closes #39785
References
Here I explained the current situation.
Output from Acceptance Testing
❯ make testacc TESTS=TestAccImageBuilderWorkflow PKG=imagebuilder
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.23.2 test ./internal/service/imagebuilder/... -v -count 1 -parallel 20 -run='TestAccImageBuilderWorkflow' -timeout 360m
2024/10/20 21:04:19 Initializing Terraform AWS Provider...
=== RUN TestAccImageBuilderWorkflow_basic
=== PAUSE TestAccImageBuilderWorkflow_basic
=== RUN TestAccImageBuilderWorkflow_disappears
=== PAUSE TestAccImageBuilderWorkflow_disappears
=== RUN TestAccImageBuilderWorkflow_changeDescription
=== PAUSE TestAccImageBuilderWorkflow_changeDescription
=== RUN TestAccImageBuilderWorkflow_description
=== PAUSE TestAccImageBuilderWorkflow_description
=== RUN TestAccImageBuilderWorkflow_kmsKeyID
=== PAUSE TestAccImageBuilderWorkflow_kmsKeyID
=== RUN TestAccImageBuilderWorkflow_tags
=== PAUSE TestAccImageBuilderWorkflow_tags
=== RUN TestAccImageBuilderWorkflow_uri
=== PAUSE TestAccImageBuilderWorkflow_uri
=== CONT TestAccImageBuilderWorkflow_basic
=== CONT TestAccImageBuilderWorkflow_kmsKeyID
=== CONT TestAccImageBuilderWorkflow_uri
=== CONT TestAccImageBuilderWorkflow_tags
=== CONT TestAccImageBuilderWorkflow_changeDescription
=== CONT TestAccImageBuilderWorkflow_description
=== CONT TestAccImageBuilderWorkflow_disappears
--- PASS: TestAccImageBuilderWorkflow_disappears (42.21s)
--- PASS: TestAccImageBuilderWorkflow_basic (47.48s)
--- PASS: TestAccImageBuilderWorkflow_changeDescription (47.56s)
--- PASS: TestAccImageBuilderWorkflow_description (47.66s)
--- PASS: TestAccImageBuilderWorkflow_kmsKeyID (49.77s)
--- PASS: TestAccImageBuilderWorkflow_uri (55.30s)
--- PASS: TestAccImageBuilderWorkflow_tags (85.21s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/imagebuilder 85.434s
...