相关疑难解决方法(0)

从aws cloudformation describe-stack获取输出

我使用以下内容通过AWS Cli 获取我想要的堆栈信息:

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如果输出的数量改变,我的结果将是意外的.

aws-cloudformation aws-cli

39
推荐指数
3
解决办法
2万
查看次数

标签 统计

aws-cli ×1

aws-cloudformation ×1