AWS CLI with IAM

AWS CLI with IAM

We can quickly create IAM group, IAM user, and policy using CLI.


1. Create an IAM Group

Use the following command to create a new IAM group:

aws iam create-group --group-name dev

AWS CLI

You can name the group whatever fits your use case.

2. Create an IAM User

Next, create a new IAM user:

aws iam create-user --user-name dev-1

AWS CLI

Ensure that each user is properly assigned unique permissions.

3. Add User to Group

Now, add the user to the created group:

aws iam add-user-to-group --user-name dev-1 --group-name dev

AWS CLI

4. Check Group Details

You can verify the group and user details with:

aws iam get-group --group-name dev

AWS CLI

5. Generate Access Key

Generate the Access Key for the user with:

aws iam create-access-key --user-name dev-1

AWS CLI

6. Delete Access Key

To delete an Access Key, use the following command:

aws iam delete-access-key --user-name dev-1 --access-key-id AKIAIOSFODNN7EXAMPLE

AWS CLI

Always ensure to securely manage and delete access keys that are no longer in use.