Skip to content
tezvyn:
Menu

The instance metadata service explained

Source: interviewMediumHow cards are made

Summary

cloud-native configuration and credential handling.

Key points

a local endpoint exposing instance identity, region, and temporary role credentials.

What's really being asked

The interviewer wants to see that you build cloud-aware applications that discover context and fetch credentials dynamically rather than hardcoding them.

The full answer

Describe the metadata service as a special link-local HTTP endpoint, on AWS at 169.254.169.254, reachable only from within the instance. It returns metadata about the instance itself: its ID, type, region and availability zone, private and public IPs, attached network interfaces, and the user-data script supplied at launch. Most importantly, when an IAM role is attached, the service vends temporary, automatically rotated credentials that the SDK retrieves transparently. Applications use this to self-configure based on region or AZ, to discover their identity for logging and service registration, and to authenticate to other cloud services without any stored secret. Azure and GCP expose equivalent metadata endpoints.

The mistakes people make

Thinking you must bake static access keys into the AMI or environment. Believing the endpoint is reachable from outside the instance. Ignoring security hardening, leaving the v1 endpoint open to server-side request forgery, where a compromised app proxies a request and steals role credentials.

What usually comes next

How does IMDSv2 mitigate SSRF with session tokens and hop limits. How are role credentials rotated and how does the SDK find them. What goes in user-data versus metadata. How do equivalents work on Azure and GCP.

A concrete example

A service launched with an IAM role granting read access to a config bucket starts up, and its SDK silently calls the metadata service to obtain temporary credentials, then reads its configuration from the bucket. The app also queries the service for its availability zone to register itself with the correct regional shard, all without a single hardcoded key, and the operator enforces IMDSv2 so a vulnerable dependency cannot exfiltrate those credentials.

Interview question

What is the most security-relevant capability the instance metadata service provides to an application?

  • a.It vends temporary, rotating credentials for the instance's attached roleCorrect
  • b.It serves static configuration files faster than object storage
  • c.It allows the instance to be reached from the public internet
  • d.It encrypts the instance's local disk automatically
Why?

The service delivers short-lived, auto-rotated role credentials so apps avoid hardcoded keys. It is link-local rather than internet-reachable, does not serve external config, and does not handle disk encryption.

Just read this? Test yourself on what you have been reading.

Read the original → docs.aws.amazon.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles