【发布时间】:2017-05-28 11:08:12
【问题描述】:
我正在使用以下内容通过 AWS Cli 获取我想要的 stack information:
aws cloudformation --region ap-southeast-2 describe-stacks --stack-name mystack
返回结果OK:
{
"Stacks": [
{
"StackId": "arn:aws:mystackid",
"LastUpdatedTime": "2017-01-13T04:59:17.472Z",
"Tags": [],
"Outputs": [
{
"OutputKey": "Ec2Sg",
"OutputValue": "sg-97e13dff"
},
{
"OutputKey": "DbUrl",
"OutputValue": "myUrl"
}
],
"CreationTime": "2017-01-13T03:27:18.893Z",
"StackName": "mystack",
"NotificationARNs": [],
"StackStatus": "UPDATE_ROLLBACK_COMPLETE",
"DisableRollback": false
}
]
}
但我不知道如何只返回 OutputValue 的值,即 myUrl
因为我不需要其余的,只需要 myUrl。
这可以通过 aws cloudformation describe-stacks 实现吗?
编辑
我才意识到我可以使用 --query:
--query "Stacks[0].Outputs[1].OutputValue"
会得到我想要的,但我想使用 DbUrl,否则如果输出的数量发生变化,我的结果将出乎意料。
【问题讨论】:
标签: amazon-cloudformation aws-cli