0 votes
1 view
in AWS by (8.9k points)

How can I find out the instance id of an ec2 instance from within the ec2 instance?

1 Answer

0 votes
by (18.5k points)

AWS sees to it that the Instance ID is available as a part of the EC2 meta data.

you can use the following command to retrieve the Instance ID.

EC2_instance_id=`wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`

You can also use the above mentioned command inside of a script to retrieve the instance ID.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...