Skip to main content

πŸ§‘β€πŸ’» 05. IAM Roles for Services

Some AWS services need to perform actions on your behalf. To grant these permissions securely, AWS uses IAM Roles.


πŸ”Ή What is an IAM Role?​

  • An IAM Role is similar to a user, but it does not have long-term credentials.
  • Services or applications assume the role to get temporary permissions.
  • Roles allow AWS services to perform actions securely without sharing your credentials.
IAM Role diagram

πŸ”‘ Common Service Roles​

ServiceRole ExamplePurpose
EC2EC2 Instance RoleAllows EC2 instances to access S3, DynamoDB, or services or even aws read access
LambdaLambda Function RoleGrants Lambda functions permissions to interact with other AWS resources
CloudFormationCloudFormation Execution RoleAllows CloudFormation to create and manage resources on your behalf

βš™οΈ How Roles Work​

  1. Create an IAM Role with the required permissions.

  2. Assign the role to the AWS service (EC2 instance, Lambda function, etc.).

  3. The service assumes the role and receives temporary credentials.

  4. Actions performed by the service are logged and controlled by the role’s policies.