1The Danger of Static Keys
IAM User Access Keys are permanent until manually deleted or rotated. This makes them a prime target for attackers. Leaked keys are the number one cause of cloud data breaches and unauthorized cryptomining.
2The Magic of STS
IAM Roles rely on the AWS Security Token Service (STS). When an entity assumes a role, STS dynamically generates temporary security credentials (an Access Key, Secret Key, and a Session Token) that automatically expire.
3Step-by-Step Breakdown
User Credentials. IAM Users use long-term credentials like passwords for the console or Access Keys for the CLI.
The Key Problem. Long-term keys are risky. If you accidentally commit them to GitHub, your account can be compromised in seconds.
Enter IAM Roles. Roles provide temporary, short-lived credentials. They are not associated with a specific person.
Assuming a Role. Entities (like EC2 instances, Lambda, or cross-account users) 'assume' a role to get permissions.
Trust Policies. Roles have two policies: a Permissions Policy (what they can do) and a Trust Policy (who can assume them).
Key Safety. What is the primary security advantage of using an IAM Role over an IAM User's access keys for an EC2 instance?
- →Faster API calls
- →Credentials are temporary and rotated automatically
- →Roles don't cost money
Cross-Account Access. Roles are the standard way to grant users in Account A access to resources in Account B.
Federation (SSO). If you log in via corporate identities (Active Directory, Okta), you are assuming an IAM Role in the background.
Best Practice. Whenever an AWS service needs to interact with another AWS service, always use an IAM Role.
Completion. You now understand how to delegate access securely.
