3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Elastic Beanstalk (Docker)で環境変数の有無によって処理をする

Last updated at Posted at 2017-01-18

What

Solution Stack: 64bit Amazon Linux 2016.09 v2.2.2 running Docker 1.11.2の場合

Why

環境別(本番、開発等)で環境変数の有無によってElastic Beanstalk上のホストで処理をしたい。例えば本番環境でのみnewrelicをインストールするとか。

How

コンテナホスト(EC2)上では直接Elastic Beanstalkの環境変数が見れないのでget-configを使う。

.ebextensionsnewrelic.config
packages: 
  yum: 
    newrelic-sysmond: [] 
  rpm: 
    newrelic: http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm
container_commands: 
  "01": 
    command: /opt/elasticbeanstalk/bin/get-config environment | jq -e -r '.NEWRELIC_KEY' && usermod -a -G docker newrelic || echo 'NEWRELIC_KEY not found'
  "02": 
    command: /opt/elasticbeanstalk/bin/get-config environment | jq -e -r '.NEWRELIC_KEY' && nrsysmond-config --set license_key=$NEWRELIC_KEY || echo 'NEWRELIC_KEY not found'
  "03": 
    command: /opt/elasticbeanstalk/bin/get-config environment | jq -e -r '.NEWRELIC_KEY' && /etc/init.d/newrelic-sysmond start || echo 'NEWRELIC_KEY not found'

この場合、NEWRELIC_KEYが存在する場合のみ設定がされる。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?