serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

Requires capabilities : [CAPABILITY_IAM]

Open avizaviz opened this issue 9 years ago • 16 comments

Hi, I am trying to enable serverless deployment with pipline and cloudformation services but failing to do so due to the following error:

My set of commands was:

c:\StackData\lambda>aws cloudformation package --template-file samTemplate.yml --s3-bucket lambdabiot --output-template-file outputTemplate.yml

Successfully packaged artifacts and wrote output template to file outputTemplate.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file c:\StackData\lambda\outputTemplate.yml --stack-name <YOUR STACK NAME>

c:\StackData\lambda>
c:\StackData\lambda>aws cloudformation deploy --template-file c:\StackData\lambda\outputTemplate.yml --stack-name ProdStack
Waiting for changeset to be created..

An error occurred (InsufficientCapabilitiesException) when calling the ExecuteChangeSet operation: Requires capabilities : [CAPABILITY_IAM]

avizaviz avatar Jan 02 '17 13:01 avizaviz

This error is a security related message: it happens when you try to create a CloudFormation stack that includes the creation of IAM related resources. You have to explicitly tell CloudFormation that you are OK with that.

To make it work, simply add the parameter --capabilities CAPABILITY_IAM to your deploy command. That should solve the problem.

Cheers!

On Mon, Jan 2, 2017, 2:30 PM Avi Zloof [email protected] wrote:

Hi, I am trying to enable serverless deployment with pipline and cloudformation services but failing to do so due to the following error:

My set of commands was:

c:\StackData\lambda>aws cloudformation package --template-file samTemplate.yml --s3-bucket lambdabiot --output-template-file outputTemplate.yml

Successfully packaged artifacts and wrote output template to file outputTemplate.yml. Execute the following command to deploy the packaged template aws cloudformation deploy --template-file c:\StackData\lambda\outputTemplate.yml --stack-name

c:\StackData\lambda> c:\StackData\lambda>aws cloudformation deploy --template-file c:\StackData\lambda\outputTemplate.yml --stack-name ProdStack Waiting for changeset to be created..

An error occurred (InsufficientCapabilitiesException) when calling the ExecuteChangeSet operation: Requires capabilities : [CAPABILITY_IAM]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/awslabs/serverless-application-model/issues/51, or mute the thread https://github.com/notifications/unsubscribe-auth/AAP995gSvsiOZf9B8l0yJ2wvP5_IVmiwks5rOPv1gaJpZM4LZAzq .

bfreis avatar Jan 02 '17 13:01 bfreis

adding --capabilities should solve the problem. Let us know if it doesn't

sanathkr avatar Jan 03 '17 19:01 sanathkr

Thanks

avizaviz avatar Jan 04 '17 06:01 avizaviz

I added the --capabilities CAPABILITY_IAM flag, but still get the the "Access denied" message in my console.

Here's the command I executed:

 aws cloudformation deploy \
   --template-file serverless-output.yaml \
   --stack-name prod \
    --capabilities CAPABILITY_IAM

anytihing else that could cause this? thx for your support!

manpenaloza avatar Mar 08 '18 14:03 manpenaloza

I have the exact same issue 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]

davidwebstar34 avatar Mar 16 '18 09:03 davidwebstar34

@davidwebstar34 For you, switch --capabilities CAPABILITY_IAM to --capabilities CAPABILITY_NAMED_IAM. If you're not letting CloudFormation name your IAM resources you need to pass this capability.

brysontyrrell avatar Mar 16 '18 15:03 brysontyrrell

i was also faced this issue ,fixed it by adding --capabilities CAPABILITY_IAM

bgkpandurang avatar Sep 06 '18 10:09 bgkpandurang

adding --capabilities CAPABILITY_IAM worked for me too. Thanks

shetty-shruti avatar Oct 08 '18 04:10 shetty-shruti

adding --capabilities CAPABILITY_IAM fixed the issue for me

ktajpuri avatar Oct 08 '18 06:10 ktajpuri

Add --capabilities CAPABILITY_NAMED_IAM This should fix the issue

piyushchordia avatar Oct 10 '18 06:10 piyushchordia

Thanks @piyushchordia, CAPABILITY_NAMED_IAM worked for me also.

I ended up with a command like:

AWS_DEFAULT_PROFILE=role_name aws cloudformation create-stack --stack-name stack_name --template-url s3_url/template file --parameters file:///local_params.json --capabilities CAPABILITY_NAMED_IAM

C-Kenny avatar Nov 21 '18 21:11 C-Kenny

i tried CAPABILITY_NAMED_IA & CAPABILITY_IAM, neither work for me, still get the same error message as avizaviz, my cmd is: aws cloudformation deploy --template-file target/output-sam.yaml --stack-name spring-boot-lambda --capabilities CAPABILITY_IAM any suggesion?@sanathkr

idolice avatar Jan 03 '19 07:01 idolice

You may sometimes need multiple capabilities, like when working with nested stacks. You can add multiple capabilities by listing them (separated by a space): --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND

See https://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html for more information about these capabilities. For most cases, you will only need one of these capabilities.

keetonian avatar Feb 08 '19 19:02 keetonian

adding --capabilities CAPABILITY_IAM fixed the issue. thxs

abodero avatar May 21 '19 18:05 abodero

Ok, 'funny' this didn't work for me:

sam deploy --config-env default --profile myprofile –-capabilities CAPABILITY_IAM

But this did:

sam deploy --config-env default --capabilities CAPABILITY_IAM --profile myprofile

heijmerikx avatar Jan 19 '23 09:01 heijmerikx

@davidwebstar34 For you, switch --capabilities CAPABILITY_IAM to --capabilities CAPABILITY_NAMED_IAM. If you're not letting CloudFormation name your IAM resources you need to pass this capability.

This was the solution for me, insetead of using CAPABILITY_IAM I used CAPABILITY_NAMED_IAM and it worked.

citizenilustre avatar Sep 26 '23 14:09 citizenilustre