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.61k stars 9k forks source link

[Enhancement]: Support for Image Builder workflows #35045

Open igordust opened 6 months ago

igordust commented 6 months ago

Description

AWS introduced the capability of creating and choosing the workflows for the image creation, here the announcement: https://aws.amazon.com/about-aws/whats-new/2023/12/ec2-image-builder-image-workflows/

This has some impact on existing resources and it requires the definition of a new one.

These the changes that I suppose should be done to support this feature:

Affected Resource(s) and/or Data Source(s)

No response

Potential Terraform Configuration

resource "aws_image_builder_workflow" "my" {
  name = "my_workflow"
  semantic_version = "1.0.0"
  description = "My Workflow"
  change-description = "This is the first release"
  data = file("myworkflow.yaml")
  # uri = "https://repooffworkflows/flow.yml" # alternative to data
  kms_key_id = aws.kms_key.my_key.id
}

resource "aws_imagebuilder_image_pipeline" "my" {
  image_recipe_arn                 = aws_imagebuilder_image_recipe.example.arn
  infrastructure_configuration_arn = aws_imagebuilder_infrastructure_configuration.example.arn
  name                             = "my_pypeline"

  # adding my custom workflow
  workflow {
    on_failure = "Abort"
    parallel_group = "test"
    parameters = []
    arn = aws_image_builder_workflow.my.arn
  }

  # adding an amazon managed workflow
  workflow {
    on_failure = "Abort"
    parallel_group = "test"
    parameters = []
    arn = "arn:aws:imagebuilder:eu-west-1:aws:workflow/test/test-image-with-wait-for-action/1.0.0/1"
  }
}

References

For resource aws_image_builder_workflow:

For datasource aws_image_builder_workflow:

For resource aws_imagebuilder_pipeline:

Would you like to implement a fix?

None

github-actions[bot] commented 6 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

bitanmallick commented 4 months ago

Would be also great if a skip_destroy feature can be added similar to image-builder-component

dbrazil-revealdata commented 3 months ago

Did this work get completed, as I noticed issue is open? https://aws.amazon.com/about-aws/whats-new/2023/12/ec2-image-builder-image-workflows/ states that this new functionality is now available, however my terraform states that "Error: Unsupported block type". Thanks

igordust commented 3 months ago

Did this work get completed, as I noticed issue is open? https://aws.amazon.com/about-aws/whats-new/2023/12/ec2-image-builder-image-workflows/ states that this new functionality is now available, however my terraform states that "Error: Unsupported block type". Thanks

The PR has been merged here: https://github.com/hashicorp/terraform-provider-aws/pull/35097#issuecomment-1889092392 and the resource should be available starting from version 5.32.0.

dbrazil-revealdata commented 3 months ago

Did this work get completed, as I noticed issue is open? https://aws.amazon.com/about-aws/whats-new/2023/12/ec2-image-builder-image-workflows/ states that this new functionality is now available, however my terraform states that "Error: Unsupported block type". Thanks

The PR has been merged here: #35097 (comment) and the resource should be available starting from version 5.32.0.

I had a look and can't see any mention of the change to the pipeline to allow custom workflows. I am trying to find out when this work is likely to get completed. Not 100% on how to read all the information. Also Terraform is at 5.43, so not sure why you mention 5.32.

kamilturek commented 3 months ago

@dbrazil-revealdata aws_imagebuilder_pipeline hasn't been yet updated to support custom workflows. I'll try looking into this soon.

dbrazil-revealdata commented 3 months ago

Thanks. It goes hand in hand with the workflows. I need to stop the default sysprep action. If I use custom workflows, it becomes a manual step.

thatderek commented 2 months ago

Howdy folks. #36953 adds much of the needed functionality to implement this. If you want to that PR a 👍 , it lays the background for this issue's resolution.

wanaxe commented 2 months ago

@thatderek Why is the change for aws_imagebuilder_image, not as expected for aws_imagebuilder_image_pipeline?

We do need it to add for the latter.

thatderek commented 2 months ago

@wanaxe I needed workflows for a project but only needed it for imagebuilder_image. However, much of what I drew up in flex.go could (and probably should) be used to add workflows to imagebuilder_image_pipeline. I am myself not to familiar with the pipelines aspect though so left the actual implementation of workflows in the latter to someone more familiar with it. The heavy lifting though I think is mostly done in flex.go.

wanaxe commented 2 months ago

@kamilturek Thank you for the PR.

All, please add a 👍to https://github.com/hashicorp/terraform-provider-aws/pull/37317, if you want it for image pipeline.