aws-cli: Manage Users, Groups and Permissions

aws-cli is a command line tool that allows us with ease to manage service s and resources on aws, in this article we are going to see some…

aws-cli: Manage Users, Groups and Permissions
Photo by Alex Kulikov on Unsplash

aws-cli is a command line tool that allows us with ease to manage service s and resources on aws, in this article we are going to see some helpful examples that we will use in our daily work

List users

The following command will list all users under this aws account

$ aws iam list-users

Create a user

The following command will create a user

$ aws iam create-user --user-name <user>

Attach a policy to a user

The following command will attach an administrator policy to a user

$ aws iam attach-user-policy --user-name <user> --policy-arn arn:aws:iam::aws:policy/AdministratorAccess

Create a new IAM group

The following command will create an IAM group named <name>

$ aws iam create-group --group-name <name>

Add a user to an IAM group

The following command will add a user to an IAM group.

$ aws iam add-user-to-group --user-name <user> --group-name <group>

Check policies attached to group

This command will list the policies that a group has attached.

$ aws iam list-attached-group-policies --group-name <group>

Check policies attached to user

Individual users can have also policies attached.

$ aws iam list-attached-user-policies --user-name <user>

Attach policy to group

This command shows how we can attach a policy to a group.

$ aws iam attach-group-policy --group-name <group> --policy-arn arn:aws:iam::aws:policy/amazonEC2FullAccess

I hope you enjoyed this short article and help you how to use aws-cli for day to day operations