6
1

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.

CodeBuildでの環境変数読み込み

Posted at

CodeBuildのBuild Spec(buildspec.yml)では環境変数をenvに列挙する必要がある。Build Spec バージョン0.2から各フェーズ(コマンド)間で環境変数を引き継げるようになったため、環境変数をファイルに記載しておき、installフェーズの最初で読み込んでしまうと管理しやすい。

参考:Shells and Commands in Build Environments

buildspec.ymlの設定例

version: 0.2
env:
  variables:
    ENV: test
phases:
  install:
    commands:
      - set -a; for f in env/${ENV}/*.env; do . ${f}; done; set +a
6
1
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
6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?