Michael Lloyd Lee mlk
Michael Lloyd Lee mlk

Reputation: 14661

aws cloudformation describe-stack-resources query by LogicalResourceId

I am attempt to retrieve a stack PhysicalResourceId using the aws command line.

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

I was expecting this to return:

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

However instead it is returning an empty array.

[]

Running the command without the query and I can see the resource. Running the command:

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

suggests that the resource exists.

Upvotes: 2

Views: 2829

Answers (1)

helloV
helloV

Reputation: 52413

How about:

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

CloudFormation and the New AWS CLI

Upvotes: 2

Related Questions