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: $?\"`"
Visit Our New Site for HR Interview Questions Answers http://www.interviewboat.com/Company/GetCompany
Sponsored Ads

0 comments:

Post a Comment