When attempting to update a cloudformation stack in the aws cli:
aws --profile dev cloudformation update-stack --stack-name mystackname --template-body file://events-list.yaml
I get the following error
An error occurred (ValidationError) when calling the UpdateStack operation: UpdateStack cannot be used with templates containing Transforms.
Because I am using the AWS Serverless transform for lambda function deployments
Transform: 'AWS::Serverless-2016-10-31'
Is there a CLI way to execute this stack update or am I going to have to work on my APM in the GUI.
You can use deploy
instead of update-stack
:
aws cloudformation deploy \
--template-file serverless-output.yaml \
--stack-name new-stack-name \
--capabilities CAPABILITY_IAM
This command is necessary because Transforms need to be applied using change sets, which the deploy
command automates for you. Refer to Working with Stacks that Contain Transforms for further discussion:
To create or update a stack with transforms, you must create a change set, and then execute it. A change set describes the actions AWS CloudFormation will take based on the processed template. During processing, AWS CloudFormation translates AWS SAM syntax into syntax that is defined by the transform. Processing can add multiples resources that you might not be aware of. For example, the specialized
AWS::Serverless::Function
resource adds an AWS Identity and Access Management (IAM) execution role and a Lambda function.To ensure that you're aware of all of the changes introduced by transforms, AWS CloudFormation requires you to use change sets. [...]
If you use the AWS CLI, you can use the
package
anddeploy
commands to reduce the number of steps for launching stacks with transforms.
Try with deploy instead of update-stack
aws cloudformation deploy \ --template-file serverless-output.yaml \ --stack-name new-stack-name \ --capabilities CAPABILITY_IAM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With