Skip to content

Instantly share code, notes, and snippets.

@seventhskye
Created October 6, 2015 08:54
Show Gist options
  • Save seventhskye/f0ddf5c83753d024f9ff to your computer and use it in GitHub Desktop.
Save seventhskye/f0ddf5c83753d024f9ff to your computer and use it in GitHub Desktop.
A script to find the instance-id and region from the metadata of an Amazon based instance.
#!/bin/bash
# Get Instance Details
INSTANCE_ID=$(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id)
REGION=$(wget -q -O- http://169.254.169.254/latest/meta-data/placement/availability-zone | sed -e 's/\([1-9]\).$/\1/g')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment