从 aws cloudformation describe-stacks 获取输出 [英] Getting Outputs from aws cloudformation describe-stacks

查看:42
本文介绍了从 aws cloudformation describe-stacks 获取输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的来获取堆栈信息 我想通过 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

返回结果正常:

{
    "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 describe-stacks 实现?

Is that possible via aws cloudformation describe-stacks?

编辑

我刚刚意识到我可以使用 --query:

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 describe-stacks 获取输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆