hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.8k stars 9.15k forks source link

[Bug]: aws_imagebuilder_workflow allows invalid value "DISTRIBUTION" for 'type' argument #39785

Open clarkhathawayaltview opened 3 days ago

clarkhathawayaltview commented 3 days ago

Terraform Core Version

1.9.7

AWS Provider Version

5.72.0

Affected Resource(s)

aws_imagebuilder_workflow

Expected Behavior

The argument type should only allow the values "BUILD" and "TEST" per the Image Builder workflow documentation

The image creation workflow framework includes the following two distinct stages. ... The workflow framework also includes a distribution stage. However, Image Builder handles the workflows for that stage.

Actual Behavior

The documentation and implementation allow for the value "DISTRIBUTION" to be passed

Relevant Error/Panic Output Snippet

Error: creating Image Builder Workflow: InvalidParameterValueException: The value supplied for parameter 'type' is not valid. Custom distribution workflows are not supported.

Terraform Configuration Files

resource aws_imagebuilder_workflow codebuild-projects {
  name = "CodeBuildProjectsDistributionWorkflow"
  version = "1.0.0"
  type = "DISTRIBUTION"
  data = file("${path.module}/codebuild-projects-distribution.workflow.yaml")
}

Steps to Reproduce

Standard plan & apply.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 days ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

stefanfreitag commented 1 day ago

Hello @clarkhathawayaltview! Thank you for reporting this issue related to the imagebuilder workflow resource.

I had a brief look into the relevant provider code section and it seems to be the case that we verify the input against the types defined in the AWS SDK for Go.

I checked out the behavior of the AWS CLI and it also dislikes the type DISTRIBUTION.

❯ aws --version
aws-cli/2.17.5 Python/3.11.8 Linux/6.11.0-8-generic exe/x86_64.ubuntu.24

❯ aws imagebuilder create-workflow --name test --type DISTRIBUTION --semantic-version 0.0.1 --data "workflow"
An error occurred (InvalidParameterValueException) when calling the CreateWorkflow operation: The value supplied for parameter 'type' is not valid. Custom distribution workflows are not supported.

even as its listed a supported input

On our end we could potentially exclude DISTRIBUTION from the validation checks, e.g. by below code change

names.AttrType: {
  Type:         schema.TypeString,
  Required:     true,
  ForceNew:     true,
  // ValidateDiagFunc: enum.Validate[awstypes.WorkflowType](),
  ValidateFunc: validation.StringInSlice([]string{string(awstypes.WorkflowTypeBuild), string(awstypes.WorkflowTypeTest)}, false),
},