Tuesday, 15 November 2016

How you will find out the instance id from within an ec2 machine?

wget -q -O - http://instance-data/latest/meta-data/instance-id

If you need programatic access to the instance ID from within a script
die() { status=$1; shift; echo "FATAL: $*"; exit $status; }
EC2_INSTANCE_ID="`wget -q -O - http://instance-data/latest/meta-data/instance-id || die \"wget instance-id has failed: $?\"`"

WHAT OTHERS ARE READING/RELATED TO THIS:

0 comments:

Post a Comment