Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use AttachGroupPolicy
with an Amazon SDK or CLI
The following code examples show how to use AttachGroupPolicy
.
- CLI
-
- Amazon CLI
-
To attach a managed policy to an IAM group
The following attach-group-policy
command attaches the Amazon managed policy named ReadOnlyAccess
to the IAM group named Finance
.
aws iam attach-group-policy \
--policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess \
--group-name Finance
This command produces no output.
For more information, see Managed policies and inline policies in the Amazon IAM User Guide.
- PowerShell
-
- Tools for PowerShell
-
Example 1: This example attaches the customer managed policy named TesterPolicy
to the IAM group Testers
. The users in that group are immediately affected by the permissions defined in the default version of that policy.
Register-IAMGroupPolicy -GroupName Testers -PolicyArn arn:aws:iam::123456789012:policy/TesterPolicy
Example 2: This example attaches the Amazon managed policy named AdministratorAccess
to the IAM group Admins
. The users in that group are immediately affected by the permissions defined in the latest version of that policy.
Register-IAMGroupPolicy -GroupName Admins -PolicyArn arn:aws:iam::aws:policy/AdministratorAccess
For a complete list of Amazon SDK developer guides and code examples, see
Using IAM with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.