How to get the Instance ID of an EC2 Instance from within the Instance

Run the below command to view the instance-id from within an EC2 Instance.

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

See also  How to enable enhanced networking on an EC2 Instance from AWS CLI