Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I allow a Group to assume a Role?

How can I allow all members of a Group to assume a Role in AWS IAM?

I tried Using the following statement but as specified in AWS IAM Principal Element, a Group can not be a Principal.

I want to achieve something like below:

{   "Version": "2012-10-17",   "Statement": [     {       "Sid": "",       "Effect": "Allow",       "Principal": {         "AWS": "arn:aws:iam::***:group/developer"       },       "Action": "sts:AssumeRole"     }   ] } 

The idea is that all members of the group group/developer should be able to assume the role. The objective is that I should be saved from having to specify each member in a group individually.

Is there a way to achieve this?

like image 595
Rentrop Avatar asked Jan 21 '16 11:01

Rentrop


People also ask

How do I allow an IAM user to assume a role?

The administrator of the specified account can grant permission to assume this role to any IAM user in that account. To do this, the administrator attaches a policy to the user or a group that grants permission for the sts:AssumeRole action. That policy must specify the role's ARN as the Resource .

How do I assign a role to a group in AWS?

In the AWS Management Console section, under Delegate console access, choose the IAM role name for the existing IAM role that you want to assign users to. If the role has not yet been created, see Creating a new role. On the Selected role page, under Manage users and groups for this role, choose Add.

Can a group be a principal AWS?

You cannot identify a user group as a principal in a policy (such as a resource-based policy) because groups relate to permissions, not authentication, and principals are authenticated IAM entities. You can specify more than one principal for each of the principal types in following sections using an array.


2 Answers

Attach a policy to the Group that grants permission to call sts:AssumeRole on the desired Role:

{     "Version": "2012-10-17",     "Statement": [         {             "Sid": "123",             "Effect": "Allow",             "Action": [                 "sts:AssumeRole"             ],             "Resource": [                 "arn:aws:iam::123456789012:role/desired-role"             ]         }     ] } 

Also, attach a Trust Policy on the Role. The sample policy (below) trusts any user in the account, but they would also need sts:AssumeRole permissions (above) to assume the role.

{   "Version": "2012-10-17",   "Statement": [     {       "Effect": "Allow",       "Principal": {         "AWS": "arn:aws:iam::123456789012:root"       },       "Action": "sts:AssumeRole"     }   ] } 
like image 160
John Rotenstein Avatar answered Sep 28 '22 05:09

John Rotenstein


You cannot specify IAM groups as principals.

You specify a principal using the Amazon Resource Name (ARN) of the AWS account, IAM user, IAM role, federated user, or assumed-role user. You cannot specify IAM groups as principals.

Per the documentation in AWS https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html

like image 36
Subtubes Avatar answered Sep 28 '22 04:09

Subtubes