logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

EC2 Metadata - Retrieve Instance Information | Online Free DevTools by Hexmos

Retrieve EC2 instance metadata with EC2 Metadata tool. Access instance ID, private IP, region, and tags. Free, fast, no registration required.

EC2 Metadata

Examples

Get the hostname:

$ curl http://instance-data/latest/meta-data/instance-id
i-xxxxxxxxxxx

Get the private ipv4 address:

$ curl -s http://169.254.169.254/latest/meta-data/local-ipv4
172.31.50.37

Get the region:

$ curl -s http://instance-data/latest/meta-data/placement/availability-zone | rev | cut -c 2- | rev
eu-west-1

Get the EC2 Tag Name Value:

TAG_NAME="Name"
INSTANCE_ID="$(curl -s http://instance-data/latest/meta-data/instance-id)"
REGION="$(curl -s http://instance-data/latest/meta-data/placement/availability-zone | rev | cut -c 2- | rev)"
TAG_VALUE="$(aws ec2 describe-tags --filters "Name=resource-id,Values=${INSTANCE_ID}" "Name=key,Values=${TAG_NAME}" --region ${REGION} --output=text | cut -f5)"

$ echo ${TAG_VALUE}
my-instance

For authenticated requests:

token=$(curl -s -XPUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 21600' http://169.254.169.254/latest/api/token)
curl -s -XGET -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/instance-id

See Also