从AWS CloudFormation描述堆栈获取输出 [英] Getting Outputs from aws cloudformation describe-stacks
本文介绍了从AWS CloudFormation描述堆栈获取输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下方法获取堆栈信息我想通过AWS Cli:
I am using the below to get the stack information I want via AWS Cli:
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
But I do not know how to return only the value of OutputValue which is myUrl
我不需要其余的,只需要myUrl。
As I do not need the rest, just myUrl.
是否可以通过aws cloudformation描述堆栈?
Is that possible via aws cloudformation describe-stacks?
编辑
我只是意识到我可以使用-查询:
I just realize I can use --query:
--query "Stacks[0].Outputs[1].OutputValue"
将完全得到我想要的,但是如果输出的数量发生变化,我想使用DbUrl,否则我的结果将是意外的。
will get exactly what I want but I would like to use DbUrl else if the number of Outputs changes, my result will be unexpected.
推荐答案
我得到了答案,使用下面的方法:
I got the answer, use the below:
--query "Stacks[0].Outputs[?OutputKey=='DbUrl'].OutputValue" --output text
希望这会帮助某人。
这篇关于从AWS CloudFormation描述堆栈获取输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文