Hi all,

Most of my builders look up an AMI based on a source_ami_filter. I'd like 
to tag the created AMI with the source AMI ID so there's an audit of the 
hierarchy. The documentation states:

tags <https://www.packer.io/docs/builders/amazon-ebs.html#tags> (object of 
> key/value strings) - Tags applied to the AMI and relevant snapshots. This 
> is a template engine <https://www.packer.io/docs/templates/engine.html> where 
> the SourceAMI variable is replaced with the source AMI ID and BuildRegion 
> variable 
> is replaced with the value of region.


So far I have tried:

{
"variables": {
"SourceAMI": ""
},
"builders": [
{
"type": "amazon-ebs",
"region": "eu-west-2",
"instance_type": "t2.small",
"ssh_username": "ec2-user",
"ami_name": "root-{{timestamp}}",
"source_ami": "ami-11130775",
"tags": {
"based_on_ami": "{{user `SourceAMI`}}"
}
}
]
}


{
"builders": [
{
"type": "amazon-ebs",
"region": "eu-west-2",
"instance_type": "t2.small",
"ssh_username": "ec2-user",
"ami_name": "root-{{timestamp}}",
"source_ami": "ami-11130775",
"tags": {
"based_on_ami": "{{user `SourceAMI`}}"
}
}
]
}


{
"builders": [
{
"type": "amazon-ebs",
"region": "eu-west-2",
"instance_type": "t2.small",
"ssh_username": "ec2-user",
"ami_name": "root-{{timestamp}}",
"source_ami": "ami-11130775",
"tags": {
"based_on_ami": "{{`SourceAMI`}}"
}
}
]
}


{
"builders": [
{
"type": "amazon-ebs",
"region": "eu-west-2",
"instance_type": "t2.small",
"ssh_username": "ec2-user",
"ami_name": "root-{{timestamp}}",
"source_ami": "ami-11130775",
"tags": {
"based_on_ami": "{{`.SourceAMI`}}"
}
}
]
}


So far none of these have worked. Can someone point me in the right 
direction please..?

Thanks
Matt

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/3b7d907b-2fc2-40f6-9e73-2ed00b501c6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to