Instance Profiles and Metadata
What You'll Learn
You'll discover how cloud compute instances securely retrieve credentials without storing them in code or configuration files.
The Credential Delivery Problem
Remember how Service-Linked Roles and Temporary Security Credentials provide secure, time-limited access? But how does a virtual machine running in the cloud actually get those credentials? You can't hardcode access keys—that violates security best practices. This is where instance profiles and metadata services come in.
How Instance Profiles Work
An instance profile is a container that passes IAM role information to an instance at launch time. Think of it like a badge holder clipped to your shirt: the badge (the role) grants you access, and the holder (instance profile) keeps it attached to you.
When you assign a role to an instance:
- The cloud provider creates or uses an instance profile
- The profile "wraps" the role and attaches it to the instance
- Your instance can now assume that role's permissions
The Metadata Service
The metadata service is a special internal HTTP endpoint available to every running instance. Your application code can query this service (usually at a well-known IP address like 169.254.169.254) to retrieve:
- Temporary credentials that are automatically rotated
- Instance identity information
- Network configuration details
The credentials retrieved through metadata are temporary—they expire and refresh automatically, implementing the Temporary Security Credentials concept you learned earlier.
The Magic Behind the Scenes
No other instance can access your instance's metadata endpoint—it's isolated by the cloud platform's networking layer. This means credentials are delivered securely without ever being stored on disk.
Key Takeaway: Instance profiles attach IAM roles to compute instances, and the metadata service delivers temporary, auto-rotating credentials directly to your running applications without hardcoding secrets.