0
votes

I have an EC2 instance and I want to know which cloud formation stack it belongs to using AWS CLI.

To do this using boto in python, refer How to determine what CloudFormation stack an AWS resource belongs to?

1

1 Answers

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

Replace i-xxxxxxxxxx by your instance-id or any other physical resource id in general.

--physical-resource-id (string): The name or unique identifier that corresponds to a physical instance ID of a resource supported by AWS CloudFormation. For example, for an Amazon Elastic Compute Cloud (EC2) instance, PhysicalResourceId corresponds to the InstanceId . You can pass the EC2 InstanceId to DescribeStackResources to find which stack the instance belongs to and what other resources are part of the stack. Required: Conditional. If you do not specify PhysicalResourceId , you must specify StackName . Default: There is no default value.

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