由LogicalResourceId执行的aws cloudformation describe-stack-resources查询

时间:2016-11-08 16:59:20

标签: amazon-web-services amazon-cloudformation aws-cli

我尝试使用aws命令行检索堆栈PhysicalResourceId。

$ aws cloudformation describe-stack-resources \
      --stack-name test-app-prometheus \
      --query 'StackResources[?LogicalResourceId=="PrometheusAutoScalingGroup"]' 

我期待着回归:

[
   {
        "ResourceStatus": "...",
        "LogicalResourceId": "...",
        "StackName": "test-app-prometheus",
        "StackId": "...",
        "PhysicalResourceId": "test-app-prometheus-PrometheusAutoScalingGroup-...",
        "ResourceType": "AWS::AutoScaling::AutoScalingGroup",
        "Timestamp": "2016-11-08T15:17:23.567Z"
   }
]

然而它返回一个空数组。

[]

运行没有查询的命令,我可以看到资源。运行命令:

$ aws cloudformation describe-stack-resources \
    --stack-name test-app-prometheus \
    --query 'StackResources[*].LogicalResourceId' \
 | grep PrometheusAutoScalingGroup
"PrometheusAutoScalingGroup",

表明该资源存在。

1 个答案:

答案 0 :(得分:1)

怎么样:

$ aws cloudformation describe-stack-resources \
      --stack-name test-app-prometheus \
      --logical-resource-id PrometheusAutoScalingGroup

CloudFormation and the New AWS CLI