EC2 http://169.254.169.254/latest/user-data returns 404

Viewed 4397

Trying to fetch EC2 userdata from win EC2 instance

http://169.254.169.254/latest/user-data

I get 404 - Not Found error

3 Answers

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

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/
Related