91

When creating a stack with CloudFormation, I get this error:

Stack update error: Requires capabilities : [CAPABILITY_IAM]

I can't find a template for adding CAPABILITIES_IAM to the CloudFormation configuration.

What are the options for resolving CAPABILITIES_IAM errors?

0

6 Answers 6

145

Turns out you need to check a box on the last screen of the stack creation. If you are using the console, just above the 'create stack' button there's a box asking you to acknowledge that you want to allow Cloudformation to modify IAM stuff. You can, of course, create the stack without the acknowledgement, which will cause the stack to fail with the CAPABILITY_IAM error (or another error, if a different capability is required).

In CodePipeline CloudFormation you can add it like this to allow execution of the created change_set in the deploy action:

Configuration:
        StackName: !Ref GitHubRepository
        ActionMode: CHANGE_SET_REPLACE
        Capabilities: CAPABILITY_NAMED_IAM
        RoleArn: arn:aws:iam::818272543125:role/events-list-codepiplinerole
        ChangeSetName: !Join ["",[!Ref GitHubRepository, "-changeset"]]
        TemplatePath: MyAppBuild::sam_post.yaml

In the aws cli append

--capabilities CAPABILITY_IAM

or

--capabilities CAPABILITY_NAMED_IAM

To your command like this:

aws cloudformation create-stack --stack-name message-store --template-body file://bucket_with_keys.yaml --parameters file://cfg_bucket_with_keys.json --capabilities CAPABILITY_NAMED_IAM

This does not apply to cloudformation --validate-template as it is not actually creating the resources.

2
12

If you are using the AWS CLI, you can add an extra parameter to the aws cloudformation create-stack command that explicitly states you want these capabilities provided.

(this is the CLI equivalent of ticking the checkbox in the other answer here).

The parameter is --capabilities CAPABILITY_IAM, so your command would look like:

aws cloudformation create-stack --stack-name $STACK_NAME --capabilities CAPABILITY_IAM

Hope that helps

5
  • Thanks for the reminder of the cli param. Added that and full code example above.
    – Eric Nord
    Jan 18, 2017 at 15:29
  • 1
    Am I wrong or does not not work with validate-template?? My full command: aws cloudformation validate-template --template-body file://sqs-template.yml --capabilities CAPABILITY_IAM
    – Michael M
    Jan 19, 2017 at 23:35
  • 2
    I came here wondering the same thing. If you see the "error" "CapabilitiesReason": "The following resource(s) require capabilities: [AWS::IAM::Role]" then that just means your template is valid and you'll have to specify the return capability when creating the stack. Source
    – Matt Klein
    Jun 11, 2017 at 16:22
  • Template will validate without the command - it is only needed when creating the stack
    – Eric Nord
    Jul 27, 2018 at 16:47
  • 3
    There's a github issue talking about this as well: github.com/awslabs/serverless-application-model/issues/51 Feb 8, 2019 at 19:41
9

Just above the create stack button, turn on acknowledge in the console. enter image description here

0
2

In case someone comes here from Google (like I did) and is using Terraform, make sure you add a capabilities argument:

resource "aws_cloudformation_stack" "cloudformation_stack" {
  # ...
  capabilities = [ "CAPABILITY_IAM" ]
}
1

If "CAPABILITY_IAM" is not supported, you can try "CAPABILITY_NAMED_IAM"

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

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 18, 2022 at 0:54
0

If anybody face the same problem trying to deploy using SAM, you just need to add the --capabilities flag:

sam deploy --guided --capabilities CAPABILITY_NAMED_IAM

using-iam-capabilities

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.