packer-plugin-amazon icon indicating copy to clipboard operation
packer-plugin-amazon copied to clipboard

Allow a different set of tags on the instance spun up by Packer

Open palladiumsai opened this issue 8 months ago • 0 comments

Description

A written overview of the feature.

Currently, the tags defined in run_tags are applied to the instance spun up by Packer. All the tags defined in run_tags are also inherited by the finished AMI. This is not always desirable, since one may want to have different set of tags on the instance for provisioning purposes. Attaching a relevant forum discussion: https://discuss.hashicorp.com/t/tags-and-run-tags/62748.

This feature addition might alleviate the pain caused in issue: https://github.com/hashicorp/packer-plugin-amazon/issues/361, where the author of the issue requests for a feature to unset the run_tags on the finished AMI. This will not be a problem if the resulting AMI does not inherit them in the first place.

Potential configuration

I propose we add a new block, say run_instance_tags similar to run_volume_tags which specifies the tags to be applied to the EC2 instance spun up by Packer. This can be a template engine like other tags block.

  • if run_tags and run_instance_tags are defined, only tags in run_instance_tags will be applied to the instance spun up by Packer
  • if run_instance_tags is not defined, then the tags in run_tags will be applied to said EC2 instance.

Alternatively, one might decide to have another block -- say final_ami_tags which determines the set of tags on the final AMI. tags currently does this, but this does not unset the tags set using run_tags

Potential References

palladiumsai avatar Feb 24 '25 11:02 palladiumsai