43

I get this error when I run create-stack for a cloudformation template that contains IAM policies.

aws cloudformation create-stack --stack-name iam-stack --template-body file://./iam.yml --capabilities CAPABILITY_IAM --profile dev

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

David Webster
  • 2,208
  • 1
  • 16
  • 27
  • Possible duplicate of [AWS Stack update error: Requires capabilities : \[CAPABILITY\_IAM\]](https://stackoverflow.com/questions/41246108/aws-stack-update-error-requires-capabilities-capability-iam) – Eric Nord May 18 '18 at 17:42

5 Answers5

58

Change --capabilities to CAPABILITY_NAMED_IAM

If you have IAM resources with custom names, you must specify CAPABILITY_NAMED_IAM. If you don't specify this parameter, this action returns an InsufficientCapabilities error.

https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html

15

As per AWS docs, If you specify a Role name in cloud formation, you must specify the CAPABILITY_NAMED_IAM value to acknowledge your template's capabilities Link

So your command should be

aws cloudformation create-stack --stack-name iam-stack --template-body file://./iam.yml --capabilities CAPABILITY_NAMED_IAM --profile dev
Jay Reddy
  • 630
  • 7
  • 6
0

In my case I needed both CAPABILITY_IAM and CAPABILITY_NAMED_IAM capabilities for a resource of type "AWS::IAM::Role".

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CloudFormation.html#createStack-property

0

If you are using AWS CodePipeline to deploy an EC2 using a CloudFormation stack, there is an option called "Capabilities" from which you can select CAPABILITY_NAMED_IAM.

james.garriss
  • 12,959
  • 7
  • 83
  • 96
0

You must pass capability as below if you're not letting CloudFormation name your IAM resources. Change from --capabilities CAPABILITY_IAM to --capabilities CAPABILITY_NAMED_IAM.

Aditya Y
  • 651
  • 6
  • 12