Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS IAM Policy to allow user to create IAM Roles (from Management Console & AWS CLI)

I've searched quite a bit but cannot find a policy to allow a user to create IAM Roles from both the management console (AWS website), and from AWS CLI.

Any help is greatly appreciated

EDIT: More clarification, the end-goal is to allow the user to create an Instance IAM Role.

like image 568
Fadi Avatar asked Jul 22 '16 14:07

Fadi


People also ask

What AWS IAM policies should be attached to IAM roles?

The IAM service supports only one type of resource-based policy called a role trust policy, which is attached to an IAM role. An IAM role is both an identity and a resource that supports resource-based policies. For that reason, you must attach both a trust policy and an identity-based policy to an IAM role.

Can you assign an IAM role to a user?

You can assign an existing IAM role to an AWS Directory Service user or group. The role must have a trust relationship with AWS Directory Service.


2 Answers

Here is the policy you need to use.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Stmt1469200763880",
      "Action": [
        "iam:AttachRolePolicy",
        "iam:CreateRole"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}
like image 164
error2007s Avatar answered Nov 04 '22 07:11

error2007s


I've been using a policy like this to allow cloudformation templates to attach roles to ec2

If this isn't enough permissions then there is a list here

http://docs.aws.amazon.com/IAM/latest/UserGuide/list_iam.html

of all the available, allowable iam permissions and you can add as much as you like

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "iam:CreateInstanceProfile",
                "iam:RemoveRoleFromInstanceProfile",
                "iam:AddRoleToInstanceProfile",
                "iam:PassRole",
                "iam:DeleteInstanceProfile"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}
like image 27
Vorsprung Avatar answered Nov 04 '22 08:11

Vorsprung