CmdID

CmdID / aws / aws iam

aws iam put-role-policy

Adds or updates an inline policy document that is embedded in the specified IAM role. AWS CLI reference

1 example 3 options Its page in the AWS CLI reference

Opens CmdID with your command. It is read in your browser and sent nowhere.

Examples

from aws-cli, each command read by CmdID

To attach a permissions policy to an IAM role

The following put-role-policy example adds a permissions policy to the role named Test-Role.

aws iam put-role-policy --role-name Test-Role --policy-name ExamplePolicy --policy-document file://AdminPolicy.jsonIdentify
--role-nameThe name of the role to associate the policy with.
--policy-nameThe name of the policy document.
--policy-documentThe policy document.

Contents of AdminPolicy.json:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "*",
            "Resource": "*"
        }
    ]
}

This command produces no output.

The policy is defined as a JSON document in the AdminPolicy.json file. (The file name and extension do not have significance.)

To attach a trust policy to a role, use the update-assume-role-policy command.

For more information, see IAM role management in the AWS IAM User Guide.

Options

3 in the AWS CLI reference
--policy-documentThe policy document.
--policy-nameThe name of the policy document.
--role-nameThe name of the role to associate the policy with.