4
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.

CloudFormationのデプロイ時の --parameter-overrides オプションの使い方

Posted at

aws cloudformation deploy コマンドでデプロイする時に環境変数を使いたい。素直にはできないようなので --parameter-overrides で代用する。

template.yml

以下のようにParametersを定義する。TargetParameterはパラメータ名なので自由に設定可能。

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  TargetParameter:
    Type: 'String'
    Default: 'foobar'
...

参照は↓のように行う。

...
  SomeEC2:
    Type: 'AWS::EC2::Instance'
    Properties:
      ImageId: !Ref TargetParameter
...

deployコマンド

デプロイ時に以下のようにパラメータを指定する。

aws cloudformation deploy \
  --template-file template.yaml \
  --capabilities CAPABILITY_IAM \
  --parameter-overrides TargetParameter=ami-bec974d8 \
  --stack-name foobar
4
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
4
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?