How to get an AWS EC2 instance ID from within that EC2 instance?
See the EC2 documentation on the subject. Run: wget -q -O – http://169.254.169.254/latest/meta-data/instance-id If you need programmatic access to the instance ID from within a script, die() { status=$1; shift; echo “FATAL: $*”; exit $status; } EC2_INSTANCE_ID=”`wget -q -O – http://169.254.169.254/latest/meta-data/instance-id || die \”wget instance-id has failed: $?\”`” Here is an example of a more … Read more