I am building a custom AMI in AWS using packer and bash + salt provisioning. However, I am in need of being able to pass some variables from my local environment to the build system and I don't really know how to do that when building using "ebp" ("eb platform" of awsebcli).
My packer json contains stuff like this:
"variables": {
"platform_name": "{{env `AWS_EB_PLATFORM_NAME`}}",
"platform_version": "{{env `AWS_EB_PLATFORM_VERSION`}}",
"platform_arn": "{{env `AWS_EB_PLATFORM_ARN`}}",
"build_app": "{{env `MY_BUILD_APP_NAME`}}",
"build_env": "{{env `MY_BUILD_ENV_NAME`}}"
},
and later:
"provisioners": [
{
"type": "file",
"source": "builder",
"destination": "/tmp/"
},
{
"type": "shell",
"execute_command": "chmod +x {{ .Path }}; {{ .Vars }} sudo {{ .Path }}",
"scripts": [
"builder/builder.sh"
],
"environment_vars": [
"AMI_BUILD_APP={{user `build_app`}}",
"AMI_BUILD_ENV={{user `build_env`}}"
I know that if I were to run packer locally, that would be enough. However, I only run "ebp create" and packer runs on the remote build environment in EC2.
Where do I need to define MY_BUILD_APP_NAME and MY_BUILD_ENV_NAME so that the packer buider environment will make them available to the bash provisioner?
Thanks!