0
votes

Based on a local AWS Cloud Formation .yaml file. I'm running the following command

aws cloudformation create-stack --stack-name someTest --template-body file://template.yaml

throwing the following error

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

I've read here that this is related to the fact that the template contains macros. In this case, inside the .yaml file, it calls the AWS::Serverless::Function, that is,

Resources:
  ResourceName:
    Type: AWS::Serverless::Function 
    ...
    ...

What are the options for resolving this issue when creating a stack?

1

1 Answers

1
votes

Solution:

Just append

--capabilities CAPABILITY_AUTO_EXPAND

to the command

aws cloudformation create-stack --stack-name someTest --template-body file://template.yaml --capabilities CAPABILITY_AUTO_EXPAND

Explanation:

As the documentation states, macros perform custom processing on templates, like operations and transformations. In this example, the AWS::Serverless transform "takes a template written in the AWS Serverless Application Model syntax and transforms and expands it into a compliant AWS CloudFormation template".

Thus, when calling the create-stack operation on a template that contains macros, it shoud specify the capability CAPABILITY_AUTO_EXPAND.