3

Trying to fetch EC2 userdata from win EC2 instance

http://169.254.169.254/latest/user-data

I get 404 - Not Found error

user829174
  • 6,132
  • 24
  • 75
  • 125
  • 1
    How are you using this? In a web browser? Perhaps: [AWS EC2 Windows 10 can't access metadata](https://stackoverflow.com/a/45116140/174777) – John Rotenstein Aug 03 '17 at 10:47

2 Answers2

3

I believe you are experiencing that because you have no EC2 user-data attached

I conducted an experiment in my AWS Console. I launched two identical EC2 instances based an Ubuntu 18.04 image. However with one of the instances I attached user-data, the other I didn't

Instance WITH user-data

$ curl http://169.254.169.254/latest
dynamic
meta-data
user-data

$ curl http://169.254.169.254/latest/user-data
(prints my specified user-data)

Instance WITHOUT user-data

$ curl http://169.254.169.254/latest
dynamic
meta-data
(notice the absence of user-data)

$ curl http://169.254.169.254/latest/user-data
.... <title>404 - Not Found</title> ....

This answers the OPs questions, but not what John Bresnahan experienced

Community
  • 1
  • 1
Sam Anthony
  • 1,669
  • 2
  • 22
  • 39
  • 1
    I can confirm this, had an instance without user data was getting 404 however the meta-data prefix working, created an identical instance with a bootstrap script and the API is working. – Mo Hajr Aug 10 '20 at 13:29
0

You MUST use the "/" at the end for all URIs.

curl http://169.254.169.254/latest/meta-data/
curl http://169.254.169.254/latest/user-data/

Alternatively, you can use the DNS record "instance-data" instead the IP. e.g.:

curl http://instance-data/latest/user-data/
medina
  • 8,051
  • 4
  • 25
  • 24