I have a nice amazon-ebs build template that I am developing to create a 
standardized AMI.  For compliance reasons, the AMI needs to be encrypted.  
For the CI testing however, we do not want to do the cross-region copy of 
the output AMI.  So it would be very helpful to be able to include the same 
common provisioner template from a couple of different builder templates.  
Specifically, one builder template for production that does the full-blown 
encryption and cross-region distribution of the AMI, and one builder 
template for CI testing that does not bother with said encryption and 
copying.  Of course I can just create separate templates for both 
environments, but the provisioner section is fairly complex, and avoiding 
breaking DRY principle is pretty important here.

The blocking issue here is this section of the template (used for prod):
        "ami_regions": "{{user `ami_regions`}}",
        "region_kms_key_ids": {
            "us-east-1": "{{user `ami_kms_encryption_key_use1`}}",
            "us-east-2": "{{user `ami_kms_encryption_key_use2`}}",
            "us-west-1": "{{user `ami_kms_encryption_key_usw1`}}",
            "us-west-2": "{{user `ami_kms_encryption_key_usw2`}}"
        },

When "ami_regions" is an empty string (for testing) instead of a 
comma-separated list (for prod), packer fails with this error:
4 error(s) occurred:

* Region us-east-2 is in region_kms_key_ids but not in ami_regions
* Region us-west-1 is in region_kms_key_ids but not in ami_regions
* Region us-west-2 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

This would be trivial to work around if it were possible to use objects for 
variable values, but oh well.

Does anyone have any suggestions here, besides keeping multiple copies of 
the provisioner code in sync between separate template files?

Thanks!
--Alex

-- 
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/03d7578d-f0b0-4d0f-b11b-462eb537e789%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to