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?

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
Eric Nord
  • 4,674
  • 3
  • 28
  • 56

6 Answers6

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.

mooreds
  • 4,932
  • 2
  • 32
  • 40
Eric Nord
  • 4,674
  • 3
  • 28
  • 56
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

gsaslis
  • 3,066
  • 2
  • 26
  • 32
  • Thanks for the reminder of the cli param. Added that and full code example above. – Eric Nord Jan 18 '17 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 '17 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](http://docs.aws.amazon.com/cli/latest/reference/cloudformation/validate-template.html) – Matt Klein Jun 11 '17 at 16:22
  • Template will validate without the command - it is only needed when creating the stack – Eric Nord Jul 27 '18 at 16:47
  • 3
    There's a github issue talking about this as well: https://github.com/awslabs/serverless-application-model/issues/51 – Keeton Hodgson Feb 08 '19 at 19:41
9

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

Aasim ali
  • 318
  • 4
  • 6
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

  • 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](/help/how-to-answer). – Community Oct 18 '22 at 00: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