iam_role attribute, which tells Terraform to assume an AWS IAM role before executing any commands. Leveraging an IAM role helps enforce least privilege, centralize credential management, and maintain clear audit trails for your infrastructure changes.

Key IAM Role Attributes
| Attribute | Description | Required / Default |
|---|---|---|
| iam_role | The Amazon Resource Name (ARN) of the IAM role that Terragrunt will assume. | Required |
| aws_profile | The name of the AWS CLI profile to source credentials from. Falls back to default/profile. | Optional |
| iam_assume_role_duration | Session duration (in seconds) for the assumed role. | Optional (default: 3600 seconds) |
| iam_assume_role_session_name | Custom session name for auditing and logging purposes when assuming the role. | Optional |
Be careful when extending the
iam_assume_role_duration. While longer sessions reduce the frequency of re-authentication, they also increase the window of risk if credentials are compromised.
Troubleshooting: Missing Permissions
If you omitiam_role and your AWS user doesn’t have direct permissions, running terragrunt apply will fail with an AccessDenied error:
Enabling IAM Role Assumption
- Create or identify an IAM role—for example,
arn:aws:iam::654654587009:role/terragrunt-role—with the necessary permissions. - Add the
iam_roleattribute to your Terragrunt configuration:
- Run the apply command:
By specifying
iam_role, you restrict deployments to users who can assume the designated role—aligning with AWS security best practices for auditable, least-privilege operations.