Elastic Beanstalk environment variables for Docker host

后端 未结 5 672
春和景丽
春和景丽 2021-02-08 04:51

I have an EB env with Docker web app (rails) properly deployed. I set several EB env variables and they are properly visible in the container. Now - I\'d like these EB env varia

5条回答
  •  我在风中等你
    2021-02-08 05:54

    I ran into the same issue, but needed the environment variables to be available during the execution of a post-deployment Bash script.

    Since the jq parser is available on the (current) Amazon Linux AMIs, I was able to acheive something similar using it to parse the JSON and then export the environment variables on the host (this is an excerpt from an ebextensions config file):

    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/post/export_env_vars_on_host.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
          temp="${envvar#\"}";
          temp="${temp/=/=\"}";
          export temp;
        done
    

提交回复
热议问题