amazon-web-services - Cloudformation AWS CLI 查询具有多个嵌套堆栈的所有堆栈资源

标签 amazon-web-services aws-cloudformation

我知道我可以通过以下方式获取堆栈资源:-

aws cloudformation describe-stack-resources \
                    --stack-name MYSTACKNAME \
                    --query 'StackResources[*].{Type:ResourceType,LogicalID:LogicalResourceId}' \
                    --output table

如果我的堆栈仅由嵌套堆栈组成,我如何获取 Cloudformation 中堆栈的所有嵌套堆栈的资源?

我可以了解如何查询父堆栈的所有堆栈。

aws cloudformation list-stacks \
                    --query 'StackSummaries[?contains(StackName, `MYSTACKNAME`) && (StackStatus==`CREATE_COMPLETE`||StackStatus==`UPDATE_COMPLETE`)].{Stack:StackName}' \
                    --output json

我不知道如何使用它来提供描述堆栈资源,它似乎只采用单独的值。

我可以将其构建到 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

关于amazon-web-services - Cloudformation AWS CLI 查询具有多个嵌套堆栈的所有堆栈资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50389873/

相关文章:

aws-cloudformation - AWS CloudFormation 模板错误 : ParameterReferenceToken is not present in the Mappings section

javascript - AWS Lambda - 错误 : Cannot find module 'uuid/v4'

amazon-web-services - Amazon SQS 如何控制重试次数

amazon-web-services - AWS CLI Update_Stack 无法传递包含/的参数值

amazon-web-services - 在 cloudformation 中为 EC2 LaunchTemplate 设置网络接口(interface)

caching - aws cloudformation CachePolicy 一般错误

r - AWS dynamodb 对 "R"编程语言的支持

amazon-web-services - AWS CDK - 部署后操作

ios - 在 iOS 上使用 AWS 将视频文件上传到现有存储桶时出现问题

amazon-web-services - 只允许CloudFormation删除CloudFormation创建的资源