Parameterizing "region_kms_key_ids"

242 views
Skip to first unread message

Alex Gottschalk

unread,
Oct 29, 2018, 5:48:00 PM10/29/18
to Packer
I have a packer recipe that uses var files to fill in account-specific parameters at various parts of the build process.  This allows us to use the same build across multiple accounts from the same source code repo.

I was very happy to discover the "region_kms_key_ids" parameter, as this will remove an in-house process for distributing the packer-built AMI across the regions we utilize.  I would like our var files to look something like this:

{
  "somevar": "someval",
  "kms_key_ids_by_region": {
    "us-east-1": "keyid",
    [...]
   }
}

However I have run into a snag, with the issue https://github.com/hashicorp/packer/issues/2441 and the error "Error reading variables in 'test.json': json: cannot unmarshal object into Go value of type string"  It looks like putting maps into a variable file is not a supported operation.  My questions are, is there any timeline for fixing this?  Is there a recommended workaround?  Having a separate manifest per account is a pretty bad DRY violation.

Thanks!
--Alex

Rickard von Essen

unread,
Oct 30, 2018, 4:22:25 AM10/30/18
to packe...@googlegroups.com
Variables are string -> string key/value pairs. You can't use objects (maps). See https://packer.io/docs/templates/user-variables.html

In your case the only solution is to use on pair per region, ie:

"variables": {
  "kms_key_eu-west-1": "",
  "kms_key_eu-north-q": ""
}

etc

--
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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/eeb756c9-3b1c-4243-ac5b-149b3e0125ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages