Skip to content

Instantly share code, notes, and snippets.

@rcherara
Last active December 10, 2018 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcherara/38451bf843974320f8e9bed6eca935b5 to your computer and use it in GitHub Desktop.
Save rcherara/38451bf843974320f8e9bed6eca935b5 to your computer and use it in GitHub Desktop.
Show Id and region of AWS EC2 instance
#!/bin/bash
instanceId=$(curl http://169.254.169.254/latest/meta-data/instance-id)
region=$(curl http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
clear
echo " The Id of this EC2 Instance is : $instanceId"
echo " The Region of this EC2 Instance is : $region"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment