Sim*_*lor 7 amazon-web-services aws-cloudformation
我知道我可以通过以下方式获取堆栈资源:-
aws cloudformation describe-stack-resources \
--stack-name MYSTACKNAME \
--query 'StackResources[*].{Type:ResourceType,LogicalID:LogicalResourceId}' \
--output table
Run Code Online (Sandbox Code Playgroud)
如果我的堆栈仅由嵌套堆栈组成,我如何获取 Cloudformation 中堆栈的所有嵌套堆栈的资源?
我可以看到如何查询父堆栈的所有堆栈。
aws cloudformation list-stacks \
--query 'StackSummaries[?contains(StackName, `MYSTACKNAME`) && (StackStatus==`CREATE_COMPLETE`||StackStatus==`UPDATE_COMPLETE`)].{Stack:StackName}' \
--output json
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何使用它来提供描述堆栈资源,它似乎只采用单独的值。
我可以将其构建到 python 脚本中,但我想我会在做之前检查一下。
谢谢
你无法实现这一命令。相反,获取属于父堆栈的所有资源的列表(嵌套堆栈详细信息),然后通过迭代该列表来描述堆栈资源。下面是我为获取所有资源而编写的命令:
for stack in $(aws cloudformation list-stacks --output text --query 'StackSummaries[?contains(StackName, `MYSTACKNAME`) && (StackStatus==`CREATE_COMPLETE`||StackStatus==`UPDATE_COMPLETE`)].[StackName]') ; do aws cloudformation describe-stack-resources --stack-name $stack --query 'StackResources[*].{Type:ResourceType,LogicalID:LogicalResourceId}' --output table ; done
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3313 次 |
| 最近记录: |