如何使用AWS CLI确定AWS资源所属的CloudFormation堆栈?

我有一个EC2实例,我想使用AWS CLI 知道它属于哪个云形成堆栈。

要在python中使用boto进行此操作,请参考How to determine what CloudFormation stack an AWS resource belongs to?

yxylwtx 回答:如何使用AWS CLI确定AWS资源所属的CloudFormation堆栈?

aws cloudformation describe-stack-resources --physical-resource-id i-xxxxxxxxxx

通常用您的实例ID或任何其他物理资源ID替换i-xxxxxxxxxx。

  

-physical-resource-id(字符串):   对应于AWS CloudFormation支持的资源的物理实例ID的名称或唯一标识符。   例如,对于Amazon Elastic Compute Cloud(EC2)实例,PhysicalResourceId对应于InstanceId。您可以将EC2 InstanceId传递给DescribeStackResources,以查找实例所属的堆栈以及该堆栈中还有哪些其他资源。   必需:有条件的。如果未指定PhysicalResourceId,则必须指定StackName。   默认:没有默认值。

参考:http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/API_DescribeStackResources.html

本文链接:https://www.f2er.com/3154595.html

大家都在问