Neat AWS feature
So I’m studying for my Amazon Web Services Associate Architect ticket at the moment and, in the coursework I’m doing, I came across this really neat feature in AWS.
If you’re on an EC2 instance (a VM), and you do..
$ curl http://169.254.169.254/latest/meta-data
You get a whole load of metadata back, like this..
ami-id ami-launch-index ami-manifest-path block-device-mapping/ events/ hostname iam/ identity-credentials/ instance-action instance-id instance-life-cycle instance-type ipv6 local-hostname local-ipv4 mac managed-ssh-keys/ metrics/ network/ placement/ profile public-hostname public-ipv4 reservation-id security-groups services/
All you need to do now is pick any of these sub-topics and query it again…
curl http://169.254.169.254/latest/meta-data/local-hostname
and you get
ip-10-16-57-144.ec2.internal
or query
curl http://169.254.169.254/latest/meta-data/instance-type
ans you get
t2.micro
Nice huh? As the feature is a URL, then you can be sure you can query it from a Flask or NodeJS app directly so an app can now be aware of what kind of hardware it’s running on, so you could even have an app that would report in telemetry to a central server to let developers know about the characteristics of the host in relation to the app performance. Quite a neat piece of internal architecture.