2.7 IAM Roles, Instance Profiles & AWS Security Token Service (STS) (Week 2 โข AWS IAM (D1: Secure 30%))
Core AWS Services: AWS STS, AWS IAM, Amazon EC2 IMDSv2
1. AWS Architectural Concept & Mechanics
IAM Roles, Instance Profiles & AWS Security Token Service (STS) (AWS IAM (D1: Secure 30%) โข AWS Services: AWS STS, AWS IAM, Amazon EC2 IMDSv2) covers Trust Policy (sts:AssumeRole โ WHO can assume) + Permissions Policy (WHAT it can do), EC2 Instance Profiles + IMDSv2 (169.254.169.254 session-oriented hop-limit=1 token protecting against SSRF!), and short-lived STS credentials (AccessKeyId, SecretAccessKey, SessionToken). In real-world AWS Solutions Architecture and on the SAA-C03 exam, architects apply this pattern for: Granting an EC2 app read access to an S3 bucket via an IAM Role + Instance Profile with automatic STS credential rotation and zero `.env` keys. Evaluating security least-privilege, Multi-AZ fault isolation, performance scaling, and monthly FinOps cost side-by-side ensures every design decision is defensible.
2. Real-World AWS & SAA-C03 Scenario Use Case
Granting an EC2 app read access to an S3 bucket via an IAM Role + Instance Profile with automatic STS credential rotation and zero .env keys.
3. Granular Subtopics & Architecture Checkpoints
- Trust Policy (sts:AssumeRole โ WHO can assume) + Permissions Policy (WHAT it can do): Core AWS architecture capability of IAM Roles, Instance Profiles & AWS Security Token Service (STS): Granting an EC2 app read access to an S3 bucket via an IAM Role + Instance Profile with automatic STS credential rotation and zero .env keys.
- EC2 Instance Profiles + IMDSv2 (169.254.169.254 session-oriented hop-limit=1 token protecting against SSRF!): Understand how 'EC2 Instance Profiles + IMDSv2 (169.254.169.254 session-oriented hop-limit=1 token protecting against SSRF!)' impacts Multi-AZ resilience, security, performance, and cost in IAM Roles, Instance Profiles & AWS Security Token Service (STS).
- Short-lived STS credentials (AccessKeyId: Understand how 'Short-lived STS credentials (AccessKeyId' impacts Multi-AZ resilience, security, performance, and cost in IAM Roles, Instance Profiles & AWS Security Token Service (STS).
- SAA-C03 Exam Trap & Architecture Guardrail (IAM Roles, Instance Profiles & AWS Security Token Service (STS)): Avoid high-frequency exam & production mistake: Leaving legacy IMDSv1 enabled without requiring IMDSv2 (HttpTokens = required) โ allows SSRF vulnerabilities on web apps to steal EC2 role credentials!
- Guided AWS Practical Lab (IAM Roles, Instance Profiles & AWS Security Token Service (STS)): Create an IAM Role EC2-S3ReadOnly-Role with trust policy ec2.amazonaws.com and inspect STS AssumeRole JSON output.
- Cost Control & Mandatory Post-Lab Resource Cleanup: IAM Roles are $0.00; if attached to a test EC2 in Week 3, terminate EC2 after lab.
4. Reference Secret-Free AWS CLI / Policy / IaC Blueprint
# Always enforce IMDSv2 on EC2: MetadataOptions -> HttpTokens: required, HttpPutResponseHopLimit: 1
5. Common SAA-C03 Exam Traps & Production Anti-Patterns
- Leaving legacy IMDSv1 enabled without requiring IMDSv2 (HttpTokens = required) โ allows SSRF vulnerabilities on web apps to steal EC2 role credentials!
- Leaving billable AWS lab resources running instead of executing post-lab cleanup: IAM Roles are $0.00; if attached to a test EC2 in Week 3, terminate EC2 after lab.
- Hardcoding static IAM access keys or ignoring Multi-AZ / KMS / Least-Privilege boundaries when designing IAM Roles, Instance Profiles & AWS Security Token Service (STS).
6. Guided AWS Practical Lab & Mandatory Cost Cleanup
Hands-On Lab: Create an IAM Role EC2-S3ReadOnly-Role with trust policy ec2.amazonaws.com and inspect STS AssumeRole JSON output.
Cost & Post-Lab Cleanup Warning: IAM Roles are $0.00; if attached to a test EC2 in Week 3, terminate EC2 after lab.
7. Cloud Architect Interview & Scenario Viva Questions
- Q: In an AWS SAA-C03 scenario or Cloud Architect interview, when do you choose IAM Roles, Instance Profiles & AWS Security Token Service (STS) (AWS STS, AWS IAM, Amazon EC2 IMDSv2), and what problem does it solve?
Architect Focus: Granting an EC2 app read access to an S3 bucket via an IAM Role + Instance Profile with automatic STS credential rotation and zero .env keys. Avoid classic SAA-C03 trap: Leaving legacy IMDSv1 enabled without requiring IMDSv2 (HttpTokens = required) โ allows SSRF vulnerabilities on web apps to steal EC2 role credentials! - Q: Walk through the architectural mechanics, security boundaries, and pricing trade-offs of IAM Roles, Instance Profiles & AWS Security Token Service (STS).
Architect Focus: Explain Trust Policy (sts:AssumeRole โ WHO can assume) + Permissions Policy (WHAT it can do), EC2 Instance Profiles + IMDSv2 (169.254.169.254 session-oriented hop-limit=1 token protecting against SSRF!), and short-lived STS credentials (AccessKeyId, SecretAccessKey, SessionToken) across availability, performance, security, and cost pillars. - Q: How did you verify IAM Roles, Instance Profiles & AWS Security Token Service (STS) hands-on in AWS and ensure zero unexpected billing afterward?
Architect Focus: Lab verification: Create an IAM Role EC2-S3ReadOnly-Role with trust policy ec2.amazonaws.com and inspect STS AssumeRole JSON output. | Cost & Cleanup Guardrail: IAM Roles are $0.00; if attached to a test EC2 in Week 3, terminate EC2 after lab.