使用 SAM 转换从 aws cli 更新 cloudformation 堆栈
Update cloudformation stack from aws cli with SAM transform
尝试在 aws cli 中更新 cloudformation 堆栈时:
aws --profile dev cloudformation update-stack --stack-name mystackname --template-body file://events-list.yaml
我收到以下错误
An error occurred (ValidationError) when calling the UpdateStack operation: UpdateStack cannot be used with templates containing Transforms.
因为我正在使用 AWS 无服务器转换进行 lambda 函数部署
Transform: 'AWS::Serverless-2016-10-31'
是否有 CLI 方法来执行此堆栈更新,或者我是否必须在 GUI 中处理我的 APM。
尝试使用 deploy 而不是 update-stack
aws cloudformation 部署\
--template-file serverless-output.yaml \
--stack-name new-stack-name \
--capabilities CAPABILITY_IAM
您可以使用 deploy
instead of update-stack
:
aws cloudformation deploy \
--template-file serverless-output.yaml \
--stack-name new-stack-name \
--capabilities CAPABILITY_IAM
此命令是必要的,因为 Transforms need to be applied using change sets, which the deploy
command automates for you. Refer to Working with Stacks that Contain Transforms 进一步讨论:
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
and deploy
commands to reduce the number of steps for launching stacks with transforms.
尝试在 aws cli 中更新 cloudformation 堆栈时:
aws --profile dev cloudformation update-stack --stack-name mystackname --template-body file://events-list.yaml
我收到以下错误
An error occurred (ValidationError) when calling the UpdateStack operation: UpdateStack cannot be used with templates containing Transforms.
因为我正在使用 AWS 无服务器转换进行 lambda 函数部署
Transform: 'AWS::Serverless-2016-10-31'
是否有 CLI 方法来执行此堆栈更新,或者我是否必须在 GUI 中处理我的 APM。
尝试使用 deploy 而不是 update-stack
aws cloudformation 部署\ --template-file serverless-output.yaml \ --stack-name new-stack-name \ --capabilities CAPABILITY_IAM
您可以使用 deploy
instead of update-stack
:
aws cloudformation deploy \
--template-file serverless-output.yaml \
--stack-name new-stack-name \
--capabilities CAPABILITY_IAM
此命令是必要的,因为 Transforms need to be applied using change sets, which the deploy
command automates for you. Refer to Working with Stacks that Contain Transforms 进一步讨论:
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.