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

2

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>
posta un anno fa14552 visualizzazioni
3 Risposte
3
Risposta accettata

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
ESPERTO
kentrad
con risposta un anno fa
profile picture
ESPERTO
verificato un mese fa
0
profile picture
ESPERTO
con risposta un anno fa
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
con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande