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

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

Closed
clarkhathawayaltview opened this issue Oct 17, 2024 · 4 comments · Fixed by #39864
Labels
bug Addresses a defect in current functionality. service/imagebuilder Issues and PRs that pertain to the imagebuilder service.
Milestone

Comments

@clarkhathawayaltview
Copy link

clarkhathawayaltview commented Oct 17, 2024

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

@clarkhathawayaltview clarkhathawayaltview added the bug Addresses a defect in current functionality. label Oct 17, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/imagebuilder Issues and PRs that pertain to the imagebuilder service. needs-triage Waiting for first response or review from a maintainer. labels Oct 17, 2024
@stefanfreitag
Copy link
Contributor

stefanfreitag commented Oct 19, 2024

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),
},

@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Oct 21, 2024
@clarkhathawayaltview
Copy link
Author

Your explanation was roughly what I had imagined the problem was. It is frustrating that their API is designed in this way but I'm pleased to see a quick response on this issue.

stefanfreitag pushed a commit to stefanfreitag/terraform-provider-aws that referenced this issue Oct 23, 2024
### Description

The documentation of the resource [`ami_imagebuilder_workflow`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/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 hashicorp#39785 

```hcl
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.

### Relations

Closes hashicorp#39785 

### References

[Here](hashicorp#39785 (comment)) I explained the current situation.

### Output from Acceptance Testing

Not required. Only documentation changed.
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.74.0 milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. service/imagebuilder Issues and PRs that pertain to the imagebuilder service.
Projects
None yet
3 participants