packer-plugin-amazon
packer-plugin-amazon copied to clipboard
Allow a different set of tags on the instance spun up by Packer
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_tagsandrun_instance_tagsare defined, only tags inrun_instance_tagswill be applied to the instance spun up by Packer - if
run_instance_tagsis not defined, then the tags inrun_tagswill 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