Which version of Packer?
On Jul 12, 2017 17:55, "Matt Brewster" <[email protected]> wrote:
> That doesn't work I'm afraid, it creates the tag but the value is "<no
> value>".
>
> On Wednesday, 12 July 2017 15:11:21 UTC+1, Rickard von Essen wrote:
>>
>> This should work:
>>
>> "tags": {
>> "based_on_ami": "{{.SourceAMI}}"
>> }
>>
>> On Jul 12, 2017 15:38, "Matt Brewster" <[email protected]> wrote:
>>
>>> 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/ms
>>> gid/packer-tool/3b7d907b-2fc2-40f6-9e73-2ed00b501c6b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/packer-tool/3b7d907b-2fc2-40f6-9e73-2ed00b501c6b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/07a2373f-3a0a-47da-8a9b-6c046c49ac1a%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/07a2373f-3a0a-47da-8a9b-6c046c49ac1a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CALz9Rt92Cx7TfyeDLY0YUzOanxF8%3DsUj977eSmbQ0SOYbo9Nuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.