How to create indetity-based policy policy allows the iam:CreateRole action

Viewed 615

I have a cloudformation template that works with AWS CLI but failed in CodePipeline due to the following error:

API: iam:CreateRole User: arn:aws:sts::xxxxxxxxxx:assumed-role/xxxxxxx-role/AWSCloudFormation is not authorized to perform: iam:CreateRole on resource: arn:aws:iam::xxxxxxxxxx:role/xxxxxxxxxInstanceRole-xxxxxxx because no identity-based policy allows the iam:CreateRole action

Can anyone show me how to create identity-based policy allows the iam:CreateRole action?

Thanks in advance!

1 Answers

You can add an inline policy to your role/AWSCloudFormation:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "iam:CreateRole",
            "Resource": "*"
        }
    ]
}
Related