Use AttachGroupPolicy with a 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-policycommand attaches the Amazon managed policy namedReadOnlyAccessto the IAM group namedFinance.aws iam attach-group-policy \ --policy-arnarn:aws:iam::aws:policy/ReadOnlyAccess\ --group-nameFinanceThis command produces no output.
For more information, see Managed policies and inline policies
in the Amazon IAM User Guide. -
For API details, see AttachGroupPolicy
in Amazon CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example attaches the customer managed policy named
TesterPolicyto the IAM groupTesters. 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/TesterPolicyExample 2: This example attaches the Amazon managed policy named
AdministratorAccessto the IAM groupAdmins. 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 API details, see AttachGroupPolicy
in Amazon Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example attaches the customer managed policy named
TesterPolicyto the IAM groupTesters. 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/TesterPolicyExample 2: This example attaches the Amazon managed policy named
AdministratorAccessto the IAM groupAdmins. 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 API details, see AttachGroupPolicy
in Amazon Tools for PowerShell Cmdlet Reference (V5).
-
For a complete list of Amazon SDK developer guides and code examples, see Using this service with an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.