aws cloudformation --region ap-southeast-2 describe-stacks --stack-name mystack
Run Code Online (Sandbox Code Playgroud)
它返回结果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
}
]
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何只返回OutputUall的值,即myUrl
因为我不需要休息,只需我的.
这可能通过aws cloudformation describe-stacks吗?
编辑
我才意识到我可以使用 - 查询:
--query "Stacks[0].Outputs[1].OutputValue"
Run Code Online (Sandbox Code Playgroud)
将得到我想要的,但我想使用DbUrl else如果输出的数量改变,我的结果将是意外的.