如何确定AWS资源所属的CloudFormation堆栈? [英] How to determine what CloudFormation stack an AWS resource belongs to?

查看:64
本文介绍了如何确定AWS资源所属的CloudFormation堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

boto3中是否存在可靠的方法来确定AWS资源所属的CloudFormation堆栈?还是它完全属于一个堆栈?假设我有一个DynamoDB表或EC2实例,如何确定它属于哪个堆栈?用于CloudFormation的boto3 API在资源级别上变得非常模糊,因此它似乎出现了。

Is there a reliable way in boto3 to determine what CloudFormation stack an AWS resource belongs to? Or if it belongs to a stack at all? Say I have a DynamoDB table or an EC2 instance, how do I find out what stack it is a member of? The boto3 API for CloudFormation gets pretty vague at the resource level, or so it appears. Any help is much appreciated.

推荐答案

您可以传递 PhysicalResourceId 资源到 desribe_stack_resources 并获取堆栈信息(如果它属于CF堆栈)
例如查找EC2主机

You can pass PhysicalResourceId of a resource to desribe_stack_resources and get the stack information if it belongs to a CF stack To find an EC2 host for example

cf = boto3.client('cloudformation')
cf.describe_stack_resources(PhysicalResourceId="i-07bd92638b049ccc4")


上的AWS文档 http://boto3.readthedocs.io/en/latest/reference/services/cloudformation.html#CloudFormation.Client.describe_stack_resources

这篇关于如何确定AWS资源所属的CloudFormation堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆