How to get an AWS EC2 instance ID from within that EC2 instance?

See the EC2 documentation on the subject. Run: wget -q -O – 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 – || die \”wget instance-id has failed: $?\”`” Here is an example of a more … Read more

Find region from within an EC2 instance

That URL ( doesn’t appear to work anymore. I get a 404 when I tried to use it. I have the following code which seems to work though: EC2_AVAIL_ZONE=`curl -s` EC2_REGION=”`echo \”$EC2_AVAIL_ZONE\” | sed ‘s/[a-z]$//’`”