get region from cli in Cape Town

0

I'm using: curl http://169.254.169.254/latest/meta-data/placement/region from the command line to get my host's location but I see I get no result when running this curl command in Cape Town.

Danie
asked 8 months ago280 views
2 Answers
1

That command uses a HTTP GET to access the instance metadata service IMDS. IMDSv1 allows a GET request but IMDSv2 uses a PUT request - is it possible that the instance has been configured to use IMDSv2?

profile pictureAWS
EXPERT
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago
0
Accepted Answer

To get the same result now on a IMDSv2 host you now run:

TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/region
Danie
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions