LoginSignup
2
3

More than 5 years have passed since last update.

CloudFormationにおけるElasticBeanstalkの環境変数の設定

Last updated at Posted at 2017-01-18

備忘録として。


CloudFormationにおけるElasticBeanstalkのリソースタイプは、AWS::ElasticBeanstalk::Environment である。
公式ドキュメントはこちら

基本的には公式ドキュメントを読めばわかるが、ElasticBeanstalk環境の環境プロパティ(要は環境変数)の設定方法が少しわかりづらかったのでメモ。

結論から言うと、OptionSettingsで下記のように設定してやればいいようだ。

OptionSettings:
  - Namespace: aws:elasticbeanstalk:application:environment
    OptionName: NODE_ENVNAME
    Value: dev

こうすることで、例えばNode.jsのアプリケーション/ワーカーなら
process.env.NODE_ENVNAMEで値が取得できるようになる。

OptionSettingsでは、その他の項目も設定できる。使用できる名前空間についてはこちらを参照のこと。
しかし、ここには、aws:elasticbeanstalk:application:environmentを使った環境プロパティの設定に関する記載がなかったので、本記事で設定方法を紹介した。

2
3
1

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
2
3