Skip to content

Instantly share code, notes, and snippets.

@MrCoffey
Created July 23, 2017 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrCoffey/ed734e0ef422260b9a5e346ace20230b to your computer and use it in GitHub Desktop.
Save MrCoffey/ed734e0ef422260b9a5e346ace20230b to your computer and use it in GitHub Desktop.
Writes custom ENV variables into aws elastic beanstalk
files:
"/opt/elasticbeanstalk/hooks/appdeploy/pre/02export_host_env_vars.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
echo Defaults:root \!requiretty >> /etc/sudoers
for envvar in `jq '.optionsettings | {"aws:elasticbeanstalk:application:environment"}[] | .[]' /opt/elasticbeanstalk/deploy/configuration/containerconfiguration`
do
host_vars="${envvar//\"/}";
host_vars="${host_vars/=/ }";
sed -i "/ENV HOST_VARS inject_here/a ENV $host_vars" /var/app/current/Dockerfile
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment