我试图在AWS Cloudformation CLI中编写一个通用脚本,将栈的参数AMI更新为新的值,而其余参数保持不变。
到目前为止,我试过这样做。
aws cloudformation update-stack --stack-name asg-xxx-123 --use-previous-template --parameters ParameterKey=ApplicationName,UsePreviousValue=true ParameterKey=ArtefactVersion,UsePreviousValue=true ParameterKey=MachineImage,ParameterValue=ami-123
请注意,有两个参数只是使用了 UsePreviousValue=true
而只对 ParameterKey=MachineImage
是需要改变的--这很好用。
然而,由于我需要它是一个通用的脚本,我如何处理一些堆栈的参数比上面更多的情况(甚至一些有不同的参数,但仍然有 ParameterKey=MachineImage
)? 有没有办法说只改变 ParameterKey=MachineImage
其余的都应该使用以前的值,而不需要明确地列在 --parameters
?
根据评论。
的 aws cloudformation update-stack
不能提供所需的功能。
然而,一个可能的解决方案是开发一个围绕着 aws cloudformation update-stack
. 包装器将允许用户只提供newchanged参数。它还将使用 描述堆栈 命令来获取现有栈参数的当前值。
有了堆栈中的当前参数和新改变的参数,包装器可以构造出有效的 aws cloudformation update-stack
命令并执行更新。