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-useruploadpolicy

Description

Takes a policy you've written and attaches it to the specified user. If a policy with that name is already attached to the user, 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 IAM.

A user can have only a limited number of policies. For more information, see Appendix A: Limitations on IAM Entities.

Syntax

iam-useruploadpolicy -u USERNAME -p POLICYNAME [-f POLICYDOCUMENTFILE | -o POLICYDOCUMENT]

Options

Name Description Required

-u USERNAME

Name of the user 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 KeyPolicy for the user named Bob. The policy is uploaded as a text string.

PROMPT> iam-useruploadpolicy -u Bob -p KeyPolicy -o {"Version":"2012-10-17","Statement":[{"Effect":​"Allow",​"Action":[​"iam:​*AccessKey*",​"iam:​*SigningCertificate*"],​"Resource":​"arn:aws:iam::​123456789012:​user/division_abc/subdivision_xyz/​Bob"}]}

The following example adds (or updates) the policy named KeyPolicy for the user named Bob. The policy is uploaded as a text file.

PROMPT> iam-useruploadpolicy -u Bob -p KeyPolicy -f C:\Policies\KeyPolicy_file.txt