Troubleshooting Permissions Issues in Deployments
This lesson explains how deployments run under many identities, and how to diagnose the permissions failures that are among the most common deployment issues.
Learning outcomes
After completing this lesson, you will be able to:
- Grant iam:PassRole correctly.
- Resolve service-linked role, service role and KMS issues.
- Follow a sequence to diagnose permission failures.
iam:PassRole
When a user or service configures a resource to use an IAM role, for example launching an instance with an instance profile, creating a Lambda function with an execution role, or starting an Automation runbook with an assume role, the caller must have iam:PassRole permission on that role. Without it, the call fails with an AccessDenied error that mentions iam:PassRole, even if the caller has full permissions on EC2 or Lambda. Scoping iam:PassRole to specific role ARNs, optionally with the iam:PassedToService condition, prevents privilege escalation by passing an administrator role.
{
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::111122223333:role/app-*",
"Condition": {"StringEquals": {"iam:PassedToService": "ec2.amazonaws.com"}}
}The following diagram compares the two teams' launches.

Service-linked roles, service roles and KMS
Service-linked roles, such as AWSServiceRoleForAutoScaling, are created automatically and let a service act on your behalf. If an Auto Scaling group launches instances with EBS volumes encrypted by a customer managed key, the key policy must allow that service-linked role to use the key (or a grant must exist); otherwise instances terminate immediately. CloudFormation service roles must have permission for every resource in the template. SCPs can deny actions regardless of IAM permissions, and the AccessDenied message now often states that an SCP was responsible. Permissions boundaries on the deploying role limit what it can do even if its policies allow more.
Service-linked or service role?
Diagnosing permission failures
The following sequence identifies the cause of a permission-related deployment failure.
-
Read the exact error
The action, resource and, increasingly, the policy type that denied it.
-
Find the call in CloudTrail
Look for errorCode AccessDenied or UnauthorizedOperation to see which principal made it, which may be a service role rather than the user.
-
Decode EC2 messages
Decode encoded authorisation messages with
aws sts decode-authorization-message. -
Simulate
Test the principal's policies with the IAM policy simulator, including SCPs and boundaries.
-
Check KMS
For encrypted resources, check the KMS key policy and grants for the calling or service-linked role.
Diagnosing an access denied error
Launch fails only for one team
Developers can create EC2 instances, but launching an instance with the app-reports instance profile fails with You are not authorized to perform this operation and an encoded message. Decoding it shows a missing iam:PassRole on arn:aws:iam::111122223333:role/app-reports. The developers' policy allows PassRole only for roles matching app-web-*. The administrator adds the reports role to the allowed list with the iam:PassedToService condition for EC2.
Which condition key limits the services a role can be passed to?
Show answer
iam:PassedToService.
Exam Tips
Remember for the exam
- Attaching a role to a resource requires iam:PassRole on that role.
- Scope PassRole by role ARN and iam:PassedToService.
- Encrypted launches need the KMS key to allow the service-linked role.
- CloudTrail shows which principal (user or service role) was denied.
- SCPs and permissions boundaries can deny even when IAM policies allow.