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.72k stars 9.08k forks source link

[Enhancement]: aws_imagebuilder_image_recipe make components block a list #31230

Open davidgaster opened 1 year ago

davidgaster commented 1 year ago

Description

For certain built AMIs, we need to only optionally add components. For example, with a managed Red Hat Linux AMI, it does not come with the aws cli preinstalled. However, Amazon Linux 2 does. Because the component configuration is an ordered instantiation of blocks, you can't define this conditional functionality.

What then happens is the RHEL AMI installs aws cli version 2 correctly, but the Amazon Linux one tries to make a duplicate install, which breaks usage of it (since it does not uninstall first).

Would be super awesome if the component block was a list of arns instead of how it stands today!

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

No response

Potential Terraform Configuration

resource "aws_imagebuilder_image_recipe" "example" {

  components = concat([
  {
    component_arn = aws_imagebuilder_component.example.arn
    parameter {
      name  = "Parameter1"
      value = "Value1"
    }
  },
  var.install_aws_cli ? {
    component_arn = aws_imagebuilder_component.example2.arn
    parameter {
      name  = "Parameter2"
      value = "Value2"
    }
  } : []
  ]
}

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue