It's not possible to pass maps as variables in Packer. I would preprocess
the template with jq/python/ruby whatever is simplest for you.

On Thu, Feb 14, 2019 at 6:10 AM Frank Dias <[email protected]> wrote:

> Hi Rickard,
>
> Can you think of  a way that we could code  something similar to
> "ami_regions": "{{user `copy_to`}}",
>  "region_kms_key_ids": ["{{user `copy_to'}}": "alias/aws/ebs"],
>
> so that the list is dynamically built using the same list from user
> copy_to.  I do not know how to structure the syntax if possible.
>
> frank
>
> On Monday, February 11, 2019 at 11:11:43 AM UTC-6, Frank Dias wrote:
>>
>> Rickard,
>>
>> I am using a user var to list the regions
>>    "ami_regions": "{{user `copy_to`}}",
>>     "ami_regions": "{{user `copy_to`}}",
>>     "region_kms_key_ids": {
>>       "eu-central-1": "alias/aws/ebs",
>>       "eu-east-1": "alias/aws/ebs",
>>       "sa-east-1": "alias/aws/ebs",
>>       "us-east-1": "alias/aws/ebs",
>>       "us-east-2": "alias/aws/ebs",
>>       "us-west-1": "alias/aws/ebs",
>>       "us-west-1": "alias/aws/ebs"
>>     },
>>
>> I can not hardcode region_kms_key_ids list, if the list does not match
>> aim_regions list one gets the following error.
>> amazon-ebs output will be in this color.
>>
>> 6 error(s) occurred:
>>
>> * Region sa-east-1 is in region_kms_key_ids but not in ami_regions
>> * Region us-east-1 is in region_kms_key_ids but not in ami_regions
>> * Region us-east-2 is in region_kms_key_ids but not in ami_regions
>> * Region eu-central-1 is in region_kms_key_ids but not in ami_regions
>> * Region eu-east-1 is in region_kms_key_ids but not in ami_regions
>> * Region us-west-2 is in ami_regions but not in region_kms_key_ids
>> how can I var the  region_kms_key_ids to match the ami_regions based on
>> user input. I have tried a few variation but no luck.
>>
>> Frank
>>
>> On Wednesday, February 6, 2019 at 1:26:17 PM UTC-6, Rickard von Essen
>> wrote:
>>>
>>> I would suggest that you just hardcode a map from all regions that might
>>> be used to "". That should solve it.
>>>
>>> On Wed, Feb 6, 2019 at 8:23 PM Rickard von Essen <[email protected]>
>>> wrote:
>>>
>>>> This was introduced in https://github.com/hashicorp/packer/pull/4948
>>>> v1.0.1
>>>>
>>>> https://github.com/hashicorp/packer/blob/master/CHANGELOG.md#101-june-19-2017
>>>>
>>>> Before that only the default ebs kms key would be used in ami_regions.
>>>>
>>>> On Wed, Feb 6, 2019 at 7:24 PM Frank Dias <[email protected]> wrote:
>>>>
>>>>> When it get to the copy portion the AMI is encrypted to be copied to
>>>>> other regions
>>>>>
>>>>> --
>>>>> 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/2d6e34ff-aeef-4c34-9af5-840f5f66224e%40googlegroups.com
>>>>> .
>>>>> 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/1b33d6eb-d035-4c22-a268-7363fda7c7f9%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/1b33d6eb-d035-4c22-a268-7363fda7c7f9%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/CALz9Rt-JvFvGoJ1sJ1tZVi0nC9hKXh8DZrZd1qEDovA2F2yMWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to