AWS Identity and Access Management
CLI Reference (API Version 2010-05-08)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

iam-roleuploadpolicy

Description

Takes a policy you've written and attaches it to the specified role. If a policy with that name is already attached to the role, it's overwritten with the new one. The command accepts either a string representing the policy, or a file containing the policy. For information about the contents of policies, refer to Using AWS Identity and Access Management.

Syntax

iam-roleuploadpolicy -r ROLENAME -p POLICYNAME [-f POLICYDOCUMENTFILE | -o POLICYDOCUMENT]

Options

Name Description Required

-r ROLENAME

Name of the role the policy is for.

Type: String

Default: None

Yes

-p POLICYNAME

Name you want to assign the policy.

Type: String

Default: None

Yes

-f POLICYDOCUMENTFILE

Path and name of the file containing the policy.

Type: String

Condition: Either -f POLICYDOCUMENTFILE or -o POLICYDOCUMENT is required, but not both.

Default: None

Conditional

-o POLICYDOCUMENT

The policy (a JSON text string).

Type: String

Condition: Either -f POLICYDOCUMENTFILE or -o POLICYDOCUMENT is required, but not both.

Default: None

Conditional

Output

If the command is successful, the output is empty.

Example

The following example adds (or updates) the policy named mypolicy for the role named myrole. The policy is uploaded as a text string.

PROMPT> iam-roleuploadpolicy -r myrole -p mypolicy -o {"Version":"2012-10-17","Statement":[{"Effect": "Allow","Action": "s3:*","Resource":"*"}]}

The following example adds (or updates) the policy named mypolicy1 for the role named myrole1. The policy is uploaded as a text file.

PROMPT> iam-roleuploadpolicy -r myrole1 -p mypolicy1 -f C:\Policies\mypolicy1_file.txt