I am getting 401 - Unauthorized when I hit meta-data API

1

Hello Team,

I am new to AWS, I have created an EC2 instance and trying to use the meta-data API from the EC2 instance and getting the below error. I checked the server time, and rebooted the instance as suggested in the forums. Not sure What I am doing wrong. Any help would be appreciated thanks!

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>401 - Unauthorized</title>
 </head>
 <body>
  <h1>401 - Unauthorized</h1>
 </body>
</html>
asked a year ago13907 views
3 Answers
2
Accepted Answer

Could be that your instance is using V2 of the meta data service. Take a look here to see how to obtain a token and pass it with the query.

Add defense in depth against open firewalls, reverse proxies, and SSRF vulnerabilities with enhancements to the EC2 Instance Metadata Service.

profile pictureAWS
EXPERT
kentrad
answered a year ago
profile picture
EXPERT
reviewed 25 days ago
0
profile picture
EXPERT
answered a year ago
0

The following section provides a short explanation for each response: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html#instance-metadata-returns

For example:

  • 401 - Unauthorized – The GET request uses an invalid token. The recommended action is to generate a new token.
AWS
answered a year 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