Skill 3.2.2

Apply instance profiles, service roles, and execution roles appropriately to authorize compute workloads

Key Concepts

EC2 instance profiles deliver role credentials through instance metadata (require IMDSv2 and a hop limit of 1 for non-container workloads). ECS has a task execution role (pull images, write logs, read secrets for the agent) and a task role (the application's permissions). EKS pods use EKS Pod Identity or IAM roles for service accounts (IRSA). Lambda uses an execution role.

Service roles let services act for you (CodeBuild, Glue, Config); service-linked roles are predefined by the service. Scope each role to least privilege and use conditions like aws:SourceArn and aws:SourceAccount in trust policies to prevent the confused deputy problem.