Wednesday, 15 January 2020

AWS CLI - Attach Policy to User


Eg: Admin policy to user
Query the user : aws iam list-attached-user-policies --user-name 'testuser2' --output table

Add Policy to the user - We need to get arn for the policy which we are adding.

aws iam attach-user-policy --user-name 'testuser2' --policy-arn arn:aws:iam::aws:policy/AdministratorAccess


Query the User:aws iam list-attached-user-policies --user-name 'testuser2' --output table
or
aws iam list-attached-user-policies --user-name 'testuser2' --output table --query 'AttachedPolicies[*].PolicyName'

No comments: