CloudFormationでこんなエラーがでたときに

1
An error occurred (InsufficientCapabilitiesException) when calling the CreateStack operation: Requires capabilities : [CAPABILITY_NAMED_IAM]

CAPABILITY_NAMED_IAMとは

CAPABILITY_IAM and CAPABILITY_NAMED_IAM

Some stack templates might include resources that can affect permissions in your AWS account; for example, by creating new AWS Identity and Access Management (IAM) users. For those stacks, you must explicitly acknowledge this by specifying one of these capabilities.

The following IAM resources require you to specify either the CAPABILITY_IAM or CAPABILITY_NAMED_IAM

・If you have IAM resources, you can specify either capability.

・If you have IAM resources with custom names, you must specify CAPABILITY_NAMED_IAM.

・If you don’t specify either of these capabilities, AWS CloudFormation returns an InsufficientCapabilities error.

CloudFormationがスタックを作成するために、特定の機能が含まれていることを明示的に示す必要がある。

  • IAMリソースがある場合は、CAPABILITY_IAMCAPABILITY_NAMED_IAMが必要になる
  • カスタム名のIAMリソースがある場合はCAPABILITY_NAMED_IAMを指定する
  • 指定がないとAWSCloudFormationはInsufficientCapabilitiesエラーを返す

CloudformationでCAPABILITIESを指定する

--capabilitiesで指定するだけ。

1
$ aws cloudformation create-stack --stack-name $(STACK_NAME) --template-body $(TEMPLATE_FILE) --parameters $(PARAMETERS_FILE) --capabilities CAPABILITY_NAMED_IAM

カスタム名のIAMリソースがあるのに、CAPABILITY_NAMED_IAMがない場合

1
2
3
$ aws cloudformation create-stack --stack-name smbcnikko-iam --template-body "file://./iam.yml" --parameters "file://./parameters.json" --capabilities CAPABILITY_IAM

An error occurred (InsufficientCapabilitiesException) when calling the CreateStack operation: Requires capabilities : [CAPABILITY_NAMED_IAM]