AWS CLI IAM User Commands: Create, Manage, and Delete Users From the Terminal

If you have ever sat at the AWS console clicking through menus just to add one new employee, you already know how slow that gets. The command line is faster, repeatable, and scriptable. In this tutorial from the Mastering AWS: Identity and Access Management series, Alston walks through every user-management operation you will realistically need, all from a single SSH session into an EC2 instance, with no local installation required.

By the time you finish reading, you will be able to spin up a new IAM user, attach a policy, drop them into a group, verify each step from the terminal, and clean everything up without ever touching the AWS console. Each command is shown in the exact order Alston uses it in the video, so you can follow along or copy-paste straight into your own session.

What You’ll Walk Out With

  • The exact CLI commands to list, create, and delete IAM users from an EC2 instance
  • How to find the correct policy ARN before attaching it to any user
  • The right sequence to detach policies and groups before a user deletion
  • How to verify every change from the command line without switching to the console
  • Why using an EC2 instance as your CLI host beats installing the AWS CLI locally on PuTTY or Cygwin
  • A complete repeatable workflow you can turn into a shell script for onboarding new employees
  • Confidence to work in IAM from the terminal without fear of breaking permissions, plus a tool at finder.platformproof.com to help you find the right online skill to deepen your AWS practice

Why Run IAM Commands From an EC2 Instance?

Alston makes a specific choice at the start of the video: he runs everything from an EC2 instance he is already SSH-ed into, not from his local machine. The reason is practical. Installing the AWS CLI on Windows via PuTTY, Cygwin, or even the native terminal introduces version mismatches, PATH conflicts, and credential configuration headaches that have nothing to do with what you are actually trying to learn.

When you SSH into an EC2 instance that has an IAM role attached, the AWS CLI is already installed and already authenticated. You skip the setup friction and get straight to the commands. For learners in 2018 when this video was recorded, that was a meaningful shortcut, and the underlying principle still holds today. Use the environment that is already configured rather than fighting your local setup.

If you want to follow along right now, the only prerequisite is an EC2 instance with an IAM role that has IAM permissions, or a local CLI configured with credentials that carry IAM access. Either way, the commands below are identical.

Step 1: List All IAM Users

The first command Alston runs is a simple audit: what users already exist in this account? Before you create anything, you want to know the current state. The command is:

aws iam list-users

Running that against Alston’s account returns three existing users: Alston, Ted, and udemy. For each user the response includes the username, the Amazon Resource Name (ARN), the creation date, and the last login timestamp. That information matters for audits. If you see a user who has never logged in and was created two years ago, that is a credential you probably want to review.

Run this command before and after every change you make in this tutorial. It is the fastest way to confirm that your actions had the effect you expected.

Step 2: Create a New IAM User

The scenario in the video is straightforward: a new employee just joined a large company, and instead of logging into the AWS console to click through the user creation wizard, Alston creates the account entirely from the terminal. The command is:

aws iam create-user –user-name Frank

AWS returns a JSON response confirming the new user. Alston then runs aws iam list-users again and finds Frank in the list alongside the original three users. Creation confirmed.

At this point Frank exists in IAM but has zero permissions. He cannot access S3, EC2, or anything else. If Frank tried to log into the console right now, every action would return an access denied error. The next two steps fix that.

Step 3: Find the Policy ARN You Need

Before you can attach a policy to Frank, you need the exact ARN for that policy. AWS uses ARNs (Amazon Resource Names) as unique identifiers for every resource in your account and in the AWS-managed policy library. To see every available policy, run:

aws iam list-policies

This returns a very long list. Alston scrolls back to the top to find AdministratorAccess and copies its ARN. For AdministratorAccess, the ARN is arn:aws:iam::aws:policy/AdministratorAccess. That is an AWS-managed policy, so the ARN is the same in every AWS account.

In a real production environment you would probably not give a new employee full administrator access on day one. Alston uses AdministratorAccess here purely to demonstrate the mechanics of attaching a policy. In practice, you would copy the ARN for a more scoped policy like PowerUserAccess or a custom policy your team has already defined.

If you already know the ARN, you can skip the list-policies step entirely and paste it directly into the next command.

Step 4: Attach a Policy to the User

With the ARN in hand, attaching the policy to Frank takes one command:

aws iam attach-user-policy –user-name Frank –policy-arn arn:aws:iam::aws:policy/AdministratorAccess

AWS returns nothing on success, which is the CLI equivalent of a thumbs up. No news is good news. To confirm the policy actually attached, Alston runs a verification command immediately after.

Step 5: Verify the Attached Policy

Never assume a command worked. After attaching the policy, Alston runs:

aws iam list-attached-user-policies –user-name Frank

The response shows AdministratorAccess listed under Frank’s account along with the policy ARN. That is the verification you need. Alston also cross-checks this in the AWS console by clicking on Frank’s user profile and confirming the policy appears there as well. Both methods agree, so Frank now has full administrator access.

This double-verification habit, terminal plus console, is worth building early. When you are managing access for dozens of employees, a missed policy attachment or an accidental extra permission can create security problems that are painful to trace later.

Step 6: Add the User to a Group

Frank has a policy attached directly to his account. Now Alston also adds him to a group called marketing. In Alston’s account there are two groups: a charm group and a marketing group. Marketing currently has zero members. Adding Frank is one command:

aws iam add-user-to-group –user-name Frank –group-name marketing

Again, no output means success. To verify, Alston checks the AWS console and sees that the marketing group now shows one member. He also verifies from the terminal in the next step.

In real IAM setups, managing permissions through groups rather than attaching policies directly to individual users is the recommended approach. When an employee changes roles, you move them from one group to another instead of hunting down every policy attached to their individual account. Alston demonstrates both methods here so you can see how they interact.

Step 7: Verify Group Membership From the Terminal

To confirm Frank is in the marketing group without touching the console, Alston uses:

aws iam get-group –group-name marketing

The response lists all users in that group, and Frank appears. Alston notes that you can also reverse the lookup and search by username if you want to see every group a specific user belongs to. The point is that the terminal gives you multiple angles to confirm the same fact, which is useful when you are building confidence with a new tool.

Wondering which tech skill will actually pay off for you?

Get a personalized match in under two minutes at finder.platformproof.com.

Step 8: Remove the User From the Group

The next part of the video simulates what happens when an employee leaves or changes departments. Alston removes Frank from the marketing group:

aws iam remove-user-from-group –user-name Frank –group-name marketing

He verifies by running aws iam get-group –group-name marketing again, and this time the users list is empty. He also checks the console to confirm marketing is back to zero members. Both match. Frank has been removed from the group.

At this point Frank still exists as a user and still has the AdministratorAccess policy attached to his individual account. The next two steps handle cleanup before the final deletion.

Step 9: Detach Policies Before Deleting the User

This step trips up a lot of beginners. You cannot delete an IAM user who still has policies directly attached. AWS will throw an error. You must detach all managed policies first. Alston uses the same ARN from Step 3:

aws iam detach-user-policy –user-name Frank –policy-arn arn:aws:iam::aws:policy/AdministratorAccess

Once that succeeds, Frank’s account is clean. No attached policies, no group memberships. He is ready to be deleted. If you have multiple policies attached to a user, you need to detach each one individually before the delete command will work. The aws iam list-attached-user-policies command from Step 5 will show you everything that needs to come off.

Step 10: Delete the IAM User

With policies detached and group memberships removed, the final deletion is straightforward:

aws iam delete-user –user-name Frank

To confirm, Alston runs aws iam list-users one final time. The list shows three users, the original three from the start of the video. Frank is gone. The console confirms the same result. Frank spent roughly ten minutes with the company, as Alston puts it in the video.

The Complete IAM User Workflow at a Glance

Here is every command from the tutorial in the exact order you would run them for a real employee onboarding and offboarding cycle:

  • aws iam list-users: audit existing users before you start
  • aws iam create-user –user-name [name]: create the new account
  • aws iam list-policies: find the ARN of the policy you need
  • aws iam attach-user-policy –user-name [name] –policy-arn [arn]: attach the policy
  • aws iam list-attached-user-policies –user-name [name]: verify the attachment
  • aws iam add-user-to-group –user-name [name] –group-name [group]: assign to a team group
  • aws iam get-group –group-name [group]: verify group membership
  • aws iam remove-user-from-group –user-name [name] –group-name [group]: remove from group on departure
  • aws iam detach-user-policy –user-name [name] –policy-arn [arn]: detach policy before deletion
  • aws iam delete-user –user-name [name]: final deletion
  • aws iam list-users: final audit to confirm clean state

Honest Drawbacks of Pure CLI IAM Management

The CLI approach shown in this video is fast and scriptable, but it has real limitations worth knowing before you adopt it as your only method.

First, the output of commands like aws iam list-policies is enormous. The full list of AWS-managed policies runs to hundreds of entries. Without piping through grep or jq, finding the ARN you need is a manual scroll job. In the video Alston scrolls back to the top of the output to find AdministratorAccess. For less familiar policy names, that search takes longer.

Second, there is no undo. If you attach the wrong policy to a user or accidentally delete the wrong account, you are correcting the mistake manually. The console at least gives you visual confirmation before each action. The CLI assumes you know what you are doing.

Third, the order of operations matters and the CLI does not enforce it. If you try to delete a user who still has attached policies, you get an error, not a guided prompt to fix it. You need to know the sequence: remove from groups, detach policies, then delete. This tutorial gives you that sequence, but if you skip a step the CLI will not coach you through recovery.

For a single user change, the console is fine. For ten users at once, or for a repeatable onboarding script, the CLI wins. Know which tool fits the situation.

Find Your X

AWS CLI proficiency is one of those skills that compounds fast. Once you can manage IAM users from the terminal, the same pattern, command plus flag plus argument, transfers to S3, EC2, RDS, and every other AWS service. The question is whether AWS is the right platform for the work you actually want to do online. If you are not sure, take two minutes and answer a few questions at finder.platformproof.com. It matches your existing skills and goals to the specific type of online income that fits you best, without the guesswork.

Frequently Asked Questions

Do I need to install the AWS CLI locally to follow this tutorial?

No. Alston specifically uses an EC2 instance accessed via SSH so that the AWS CLI is already present and authenticated through the instance’s IAM role. If you want to run the same commands locally, you can install the AWS CLI and configure it with aws configure, but the EC2 approach removes that setup step entirely.

What is an ARN and why do I need it to attach a policy?

ARN stands for Amazon Resource Name. It is a unique identifier that AWS assigns to every resource in its system, including policies, users, buckets, and instances. When you attach a policy to a user from the CLI, AWS needs the full ARN rather than just the policy name because policy names are not unique across accounts. The ARN includes the account ID and the policy path, making it globally unique.

Why can’t I just delete a user without detaching their policies first?

AWS enforces this as a safety check. If you could delete a user with attached policies in one command, it would be easy to accidentally remove an account that has critical permissions without realizing what you are erasing. By requiring you to detach policies first, AWS forces you to review what the user had access to before the account disappears. It is an intentional friction point.

Is it better to attach policies directly to users or manage them through groups?

Groups are the recommended approach for most real organizations. When you manage permissions through groups, changing a user’s access means moving them from one group to another rather than auditing and updating every individual policy on their account. Direct user policy attachment, which Alston demonstrates in this video, is useful for one-off situations or for understanding the mechanics, but at scale, groups keep IAM manageable.

Can I list all the groups a specific user belongs to from the CLI?

Yes. The command is aws iam list-groups-for-user –user-name [name]. Alston does not use this specific command in the video, but it is the complement to aws iam get-group. One looks up a group and returns its members; the other looks up a user and returns their groups. Both are useful for auditing.

What happens if I forget to remove a user from a group before deleting them?

Unlike attached policies, AWS will actually let you delete a user who is still a member of groups. The deletion will succeed and the group’s member count will drop automatically. However, it is still good practice to remove the user from groups manually before deletion so you have a clear audit trail and you confirm the group’s remaining membership before any changes take effect.

How do I give a new IAM user the ability to log into the AWS console?

Creating an IAM user with aws iam create-user does not automatically give them console access. To let them log in through the browser, you also need to create a login profile with a password using aws iam create-login-profile –user-name [name] –password [password] –password-reset-required. That command is not covered in this particular video, which focuses on user and policy management rather than login setup.

Does this workflow still apply in 2024 or has IAM changed significantly since 2018?

The core IAM user commands shown in this video have remained stable. AWS has added newer authentication options like IAM Identity Center (formerly AWS SSO) that are now the recommended approach for workforce access in larger organizations, but the underlying aws iam commands for creating users, attaching policies, and managing groups work the same way they did in 2018. The syntax you see here is still valid and widely used.

Read Next

If you are working through the Mastering AWS series, the next logical skill to build is hands-on EC2 and EBS management. Once your IAM users are set up with the right permissions, they need to be able to provision and attach storage to their instances.

Read How to Create an EBS Volume and Attach to EC2 for the step-by-step walkthrough on adding persistent block storage to a running instance.

Sources

  • Alston Godbolt, “aws cli user commands (2018),” Mastering AWS: Identity and Access Management series, YouTube, 2018
  • AWS Documentation: aws iam CLI command reference, docs.aws.amazon.com/cli/latest/reference/iam/
  • AWS Documentation: IAM best practices, docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html

Related Reading


Helping 1 million working adults make their first $3,000 online with the skills they already have. Alston Godbolt, Platform Proof.