代码之家  ›  专栏  ›  技术社区  ›  Michael Lloyd Lee mlk

aws cloudformation通过LogicalResourceId描述堆栈资源查询

  •  1
  • Michael Lloyd Lee mlk  · 技术社区  · 9 年前

    我尝试使用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 回复  |  直到 9 年前
        1
  •  2
  •   helloV    9 年前

    怎么样:

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

    CloudFormation and the New AWS CLI

    推荐文章