The following code examples show how to use PutUserPolicy
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:
- AWS CLI
-
To attach a policy to an IAM user
The following
put-user-policy
command attaches a policy to the IAM user namedBob
.aws iam put-user-policy \ --user-name
Bob
\ --policy-nameExamplePolicy
\ --policy-documentfile://AdminPolicy.json
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.)
For more information, see Adding and removing IAM identity permissions in the AWS IAM User Guide.
-
For API details, see PutUserPolicy
in AWS CLI Command Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.