Skip to content

Instantly share code, notes, and snippets.

@amosshapira
Created February 1, 2016 04:58
Show Gist options
  • Select an option

  • Save amosshapira/1dd87ff4075d19052d5f to your computer and use it in GitHub Desktop.

Select an option

Save amosshapira/1dd87ff4075d19052d5f to your computer and use it in GitHub Desktop.
Fetch the name of the CloudFormation stack of an EC2 instance
# get instance-id from meta-data, if you like:
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 describe-instances \
--instance-id $INSTANCE_ID \
--query 'Reservations[*].Instances[*].Tags[?Key==`aws:cloudformation:stack-name`].Value' \
--output text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment