Skip to main content

Overview

The IAM Role resource provides identity-based access control for AWS services and resources. It is a thin wrapper around the CDK IAM Role with the same properties and methods, used throughout Fjall for service permissions.

Resource Class

Basic Usage

Configuration Options

All standard CDK Role properties are supported:

Common Patterns

Lambda Execution Role

ECS Task Role

EC2 Instance Role

Service Principals

AWS Service Principals

Federated Principals

Account Principals

Inline Policies

Single Statement

Multiple Policies

Managed Policies

AWS Managed Policies

Customer Managed Policies

Adding Permissions

Add to Policy

Grant Methods

Trust Relationships

Basic Trust Policy

Conditional Trust

Session Tags

Role Boundaries

Permission Boundaries

Integration Examples

With Lambda Function

With ECS Task

With CodeBuild

Complete Example

Best Practices

  1. Use least privilege - Only grant required permissions
  2. Prefer managed policies for common patterns
  3. Use conditions to restrict access further
  4. Enable MFA for sensitive roles
  5. Set appropriate session duration
  6. Use permission boundaries in multi-tenant environments
  7. Tag roles for cost allocation and compliance

Security Considerations

Avoid Wildcard Permissions

Use Conditions

Troubleshooting

Common Issues

  1. Access denied: Check trust policy and permissions
  2. Invalid principal: Verify service principal format
  3. Policy size limit: Use managed policies for large policies
  4. Circular dependencies: Use addToPolicy after creation

Debug Commands

Next Steps

Secrets Manager

Store and grant access to credentials and API keys.

KMS Key

Encrypt data and scope decryption to specific roles.

Lambda Function

Attach an execution role to a serverless function.

ECS Cluster

Assign task and execution roles to containers.