CloudFormation
aws-cli

aws cloudformation deployがいつのまにかロール指定とデフォルトパラメータに対応してた

More than 1 year has passed since last update.

自分みたいに気づいていない人もいると思うので、残しておく


ロール指定に対応

--role-arn指定できるようになった

おかげでpackage後create-change-set/execute-change-setをしなくて良くなって嬉しい

--notification-arnsにも対応してる

新しいバージョン

$ aws --version

aws-cli/1.11.141 Python/3.4.2 Darwin/16.7.0 botocore/1.6.8
$ aws cloudformation deploy help | head -30
DEPLOY() DEPLOY()

NAME
deploy -

DESCRIPTION
Deploys the specified AWS CloudFormation template by creating and then
executing a change set. The command terminates after AWS CloudFormation
executes the change set. If you want to view the change set before AWS
CloudFormation executes it, use the --no-execute-changeset flag.

To update a stack, specify the name of an existing stack. To create a
new stack, specify a new stack name.

SYNOPSIS
deploy
--template-file <value>
--stack-name <value>
[--parameter-overrides <value> [<value>...]]
[--capabilities <value> [<value>...]]
[--no-execute-changeset]
[--role-arn <value>]
[--notification-arns <value> [<value>...]]

古いバージョン

$ aws --version

aws-cli/1.11.128 Python/3.4.2 Darwin/16.7.0 botocore/1.5.91
$ aws cloudformation deploy help | head -30
DEPLOY() DEPLOY()

NAME
deploy -

DESCRIPTION
Deploys the specified AWS CloudFormation template by creating and then
executing a change set. The command terminates after AWS CloudFormation
executes the change set. If you want to view the change set before AWS
CloudFormation executes it, use the --no-execute-changeset flag.

To update a stack, specify the name of an existing stack. To create a
new stack, specify a new stack name.

SYNOPSIS
deploy
--template-file <value>
--stack-name <value>
[--parameter-overrides <value> [<value>...]]
[--capabilities <value> [<value>...]]
[--no-execute-changeset]


デフォルトパラメータに対応

ちょっと前はエラー出てたので諦めてたんだけど、久々に試したらできた

デフォルト値のあるテンプレートでcreate-stack/create-change-setを使わずに

deployがやりやすくなって嬉しい

テスト用テンプレート

AWSTemplateFormatVersion: '2010-09-09'

Parameters:
BucketName:
Type: String
Default: "example-bucket-name-1234567890"
Resources:
S3:
Type: "AWS::S3::Bucket"
Properties:
BucketName: !Ref BucketName

新しいバージョン

$ aws --version

aws-cli/1.11.141 Python/3.4.2 Darwin/16.7.0 botocore/1.6.8
$ aws cloudformation deploy --template-file createbucket.yml --stack-name testcreatebucket
Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - testcreatebucket

古いバージョン

$ aws --version

aws-cli/1.11.19 Python/3.4.2 Darwin/16.7.0 botocore/1.4.76
$ aws cloudformation deploy --template-file createbucket.yml --stack-name testcreatebucket

An error occurred (ValidationError) when calling the CreateChangeSet operation: Cannot specify UsePreviousValue on Parameters when ChangeSetType is CREATE