AWS CloudFormation Stack update error: Requires capabilities : [CAPABILITY_IAM]

37,351

Solution 1

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.

Solution 2

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

Solution 3

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

Share:
37,351
Eric Nord
Author by

Eric Nord

LinkedIn

Updated on July 05, 2022

Comments

  • Eric Nord
    Eric Nord almost 2 years

    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?

  • Eric Nord
    Eric Nord over 7 years
    Thanks for the reminder of the cli param. Added that and full code example above.
  • StartupGuy
    StartupGuy over 7 years
    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
  • Matt Klein
    Matt Klein almost 7 years
    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
  • Eric Nord
    Eric Nord almost 6 years
    Template will validate without the command - it is only needed when creating the stack
  • Keeton Hodgson
    Keeton Hodgson about 5 years
    There's a github issue talking about this as well: github.com/awslabs/serverless-application-model/issues/51