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.84k stars 9.19k forks source link

[Enhancement]: aws_ami_from_instance to tag snapshots as well #29869

Open XerXi opened 1 year ago

XerXi commented 1 year ago

Description

Hello, I am creating an ec2 ami with:

resource "aws_ami_from_instance" "ecc" {
    name                = "somename"
    source_instance_id  = data.aws_instance.ecc.id
    tags = {
        Name            = "somename"
    }
  }
}

However it applies the tags only to the ami itself, while leaving the related ebs snapshot without any tags.

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

aws_ami_from_instance

Potential Terraform Configuration

Have the option to choose "Tag image and snapshots together" with true/false

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

mroberts14 commented 1 year ago

Looks to be somewhat related to https://github.com/hashicorp/terraform-provider-aws/issues/13493 and possible solution is here : https://github.com/hashicorp/terraform-provider-aws/issues/13493#issuecomment-643548955

However, it would be nice to have an option within the actual resource aws_ami_from_instance to apply snapshot tags

XerXi commented 1 year ago

Thing is with "aws_ec2_tag" it adds the tags after the image and snapshots are created, which require you to have rights to tag stuff. For example, in our organization we have divided the resources of various teams by a tag and allow tagging only during creation of an ec2 object, as not to be able to "commandeer" objects of other teams by adding a tag later