我尝试使用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",
表明资源存在。