The following code examples show how to use AttachUserPolicy
.
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 managed policy to an IAM user
The following
attach-user-policy
command attaches the AWS managed policy namedAdministratorAccess
to the IAM user namedAlice
.aws iam attach-user-policy \ --policy-arn
arn:aws:iam::aws:policy/AdministratorAccess
\ --user-nameAlice
This command produces no output.
For more information, see Managed policies and inline policies in the AWS IAM User Guide.
-
For API details, see AttachUserPolicy
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.