Bobcares

Not authorized to perform iam:PassRole error – How to resolve

by | Jun 11, 2021

Wondering how to resolve “Not authorized to perform iam:PassRole” error? We can help you.

At Bobcares we assist our customers with several AWS queries as part of our AWS Support Services for AWS users, and online service providers.

Today, let us discuss how our Support Techs resolved above error.

 

Not authorized to perform iam:PassRole error

Typical error looks as shown below:

ClientError: An error occurred (AccessDenied) when calling the PutLifecycleHook operation: User: arn:aws:sts::111122223333:assumed-role/Testrole/Diego is not authorized to perform: iam:PassRole on resource: arn:aws:iam::111122223333:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling

When you create a service-linked role, you must have permission to pass that role to the service.

Some services automatically create a service-linked role in your account when you perform an action in that service.

For example, Amazon EC2 Auto Scaling creates the AWSServiceRoleForAutoScaling service-linked role for you the first time that you create an Auto Scaling group.

If you try to create an Auto Scaling group without the PassRole permission, you receive the above error.

To fix this error, the administrator need to add the iam:PassRole permission for user.

 

How to resolve “not authorized to perform iam:PassRole” error?

In order to pass a role to an AWS service, a user must have permissions to pass the role to the service.

To allow a user to pass a role to an AWS service, you must grant the PassRole permission to the user’s IAM user, role, or group.

A user can pass a role ARN as a parameter in any API operation that uses the role to assign permissions to the service.

The service then checks whether that user has the iam:PassRole permission.

In order to grant a user the ability to pass any of an approved set of roles to the Amazon EC2 service upon launching an instance.

You need three elements:

  • Firstly, an IAM permissions policy attached to the role that determines what the role can do.

Scope permissions to only the actions that the role must perform, and to only the resources that the role needs for those actions.

You can use AWS managed or customer-created IAM permissions policy.

{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Action": [ "A list of the permissions the role is allowed to use" ], "Resource": [ "A list of the resources the role is allowed to access" ] } }
  • A trust policy for the role that allows the service to assume the role.

For example, you could attach the following trust policy to the role with the UpdateAssumeRolePolicy action.

This trust policy allows Amazon EC2 to use the role and the permissions attached to the role.

{
"Version": "2012-10-17",
"Statement": {
"Sid": "TrustPolicyStatementThatAllowsEC2ServiceToAssumeTheAttachedRole",
"Effect": "Allow",
"Principal": { "Service": "ec2.amazonaws.com" },
"Action": "sts:AssumeRole"
}
}
  • An IAM permissions policy attached to the IAM user that allows the user to pass only those roles that are approved.

iam:PassRole usually is accompanied by iam:GetRole so that the user can get the details of the role to be passed.

Please find the example below.

{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"iam:GetRole",
"iam:PassRole"
],
"Resource": "arn:aws:iam::<account-id>:role/EC2-roles-for-XYZ-*" }] }

Now the user can start an Amazon EC2 instance with an assigned role.

The permissions policies attached to the role determine what the instance can do.

[Need help with AWS error? We’d be happy to assist]

 

Conclusion

In short, this error occurs when you try to create an Auto Scaling group without the PassRole permission. Today we saw the steps followed by our Support Techs to resolve it.

 

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF