我正在编写一个脚本来创建各种 CloudFormation 堆栈,并希望在上一个堆栈完成后启动下一个堆栈。我希望使用 'stack-exists' subcommand 而不是“随便 sleep ” 。相关堆栈的 ID 位于 StackId 变量中,也位于 StackId 明文文件中。 事情是这样的:
$ echo ${StackId}
"arn:aws:cloudformation:eu-central-1:461950495720:stack/CF-VPC-NEW/8031d670-aa78-11ec-986e-02784df577a8"
$ aws cloudformation wait stack-exists --stack-name ${StackId}
Waiter StackExists failed: Max attempts exceeded. Previously accepted state: Matched expected service error code: ValidationError
$ cat StackId
"arn:aws:cloudformation:eu-central-1:461950495720:stack/CF-VPC-NEW/8031d670-aa78-11ec-986e-02784df577a8"
$ aws cloudformation wait stack-exists --stack-name `cat StackId`
Waiter StackExists failed: Max attempts exceeded. Previously accepted state: Matched expected service error code: ValidationError
$ aws cloudformation wait stack-exists --stack-name "arn:aws:cloudformation:eu-central-1:461950495720:stack/CF-VPC-NEW/8031d670-aa78-11ec-986e-02784df577a8"
$ echo $?
0
有什么想法吗?
最佳答案
您的StackId
包含引号。所以它被创建为:
StackId=\"arn:aws:cloudformation:eu-central-1:461950495720:stack/CF-VPC-NEW/8031d670-aa78-11ec-986e-02784df577a8\"
而不是
StackId="arn:aws:cloudformation:eu-central-1:461950495720:stack/CF-VPC-NEW/8031d670-aa78-11ec-986e-02784df577a8"
关于amazon-web-services - 将选项值从变量或文件传递给 AWS CLI 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71583400/