amazon-web-services - 将选项值从变量或文件传递给 AWS CLI 命令

标签 amazon-web-services aws-cloudformation aws-cli

我正在编写一个脚本来创建各种 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/

相关文章:

linux - 使用 AWS CLI 进行 Bash - 无法找到凭证

amazon-web-services - 如何使用 AWS CLI 确定 AWS 资源属于哪个 CloudFormation 堆栈?

c# - Amazon SES 电子邮件地址未验证

amazon-web-services - 在 aws-cli 中,如何根据条件从 DynamoDB 中删除项目?

aws-cloudformation - 具有 Cloudformation WAFRegional 的 SAM API 网关

amazon-s3 - 使用 Cloudformation 在 S3 存储桶内创建文件夹

amazon-web-services - 如何在 AWS CLI 中过滤不等于

amazon-web-services - 可用性 SLA 与为可用性而设计

angular - 让 Amazon Cognito 使用 angular2 和 typescript

amazon-web-services - 为单个服务器创建基本 AWS CloudFormation 模板