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
  • 5,844
  • 21
  • 71
  • 117
  • 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

3 Answers3

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,489
  • 2
  • 17
  • 37
  • 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
  • 7,816
  • 4
  • 24
  • 24
-1

I am seeing this as well:

root@ip-172-31-29-121:/var/lib/cloud# curl http://169.254.169.254/latest/
dynamic
meta-data
user-dataroot@ip-172-31-29-121:/var/lib/cloud#
root@ip-172-31-29-121:/var/lib/cloud# curl http://169.254.169.254/latest/user-data
<?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>404 - Not Found</title>
 </head>
 <body>
  <h1>404 - Not Found</h1>
 </body>
</html>

Note that the first curl command indicates that the data should be there.