Packer: Copied AMIs Missing Tags

Created on 11 Nov 2016  路  9Comments  路  Source: hashicorp/packer

When creating new AMIs, and copying them to other regions, the tags don't get applied, even though Packer claims they were applied.

buildeamazon wontfix

Most helpful comment

Any chance this can be revisited? We build numerous AMI's that are copied to other AWS accounts we own (separated for security reasons), and have to update the tags on the AMI's with a script after the fact. Would be great if we could post-process these with Packer.

All 9 comments

I can't reproduce this.

Could you see if it works if you correct the syntax, so that you have:

"ami_regions": [ "us-east-1", "us-west-1", "us-west-2" ],

Giving it a shot now. Weirdly enough, the copies complete successfully, it's just the tags that are missing.

@rickard-von-essen so, no dice. Changing the format didn't change the tags.

I'm trying a build that uses the proper format for the ami_users to see if that makes a difference.

Closing. The issue seems to be that the tags are only visible to the owner AWS account, rather than the shared accounts. Thanks @rickard-von-essen!

Any chance this can be revisited? We build numerous AMI's that are copied to other AWS accounts we own (separated for security reasons), and have to update the tags on the AMI's with a script after the fact. Would be great if we could post-process these with Packer.

Would be nice to have an optional flag to enable copying of tags when ami_users is specified.

Actually it's not possible to copy tags available for another account. You can tag an AMI you can use in that account. But since we don't want to handle multiple accounts from Packer it's not possible.

For people that want this my recommendation is that you parse the AMI-id from a manifest file and use that in a script to tag the AMI in your other accounts.

@rickard-von-essen fair enough. I wrote a wrapper script that uses the awscli to copy the tags. Below is the meat of it.

```
ami_tags=$(aws ec2 --profile "$source_profile" --region "$ami_region" describe-images --image-ids "$ami_id" | jq -c '.Images[].Tags')

aws ec2 --profile "$destination_profile" --region $ami_region create-tags --resources $ami_id --tags $ami_tags
````

@szinck That sounds reasonable, but I think the only way to see that get added is to write it yourself. It depends how complicated it ends up being, but I probably wouldn't have any problems merging something like that

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shantanugadgil picture shantanugadgil  路  3Comments

wduncanfraser picture wduncanfraser  路  3Comments

sourav82 picture sourav82  路  3Comments

DanielBo picture DanielBo  路  3Comments

mwhooker picture mwhooker  路  3Comments