AWS IAM CLI Tutorial: Create Users, Set Passwords, and Manage Access Keys

If you are chasing AWS certifications, IAM is the subject that will show up on every single exam. The Solutions Architect Associate, the Developer Associate, the SysOps Administrator, the Security Specialty, they all test you on Identity and Access Management. But reading IAM documentation and actually typing IAM commands are two different things. The hands-on exercises in this tutorial series are exactly the kind of practice that moved the author from studying to certified, and this post walks you through every step in plain language.

This tutorial was recorded inside a Cloud9 environment and every action was immediately verified in the AWS Management Console. You will see the same approach here: the command, what the output means, and what changes in the console so you know the command actually worked. By the end you will have created an IAM user, given that user a console login password, generated programmatic access keys, hit the per-user key limit on purpose so you know what the error looks like, and placed the user inside a group that controls permissions through an attached policy.

What You’ll Walk Out With

  • The exact CLI command to create a new IAM user from the terminal
  • How to set a console password so the user can log in to the AWS Management Console
  • How to generate an access key ID and secret access key for SDK and CLI use
  • Why AWS enforces a hard limit of two access keys per user and what error you get when you exceed it
  • How to add a user to a group so they inherit the group’s policies instead of needing individual permission assignments
  • Where to verify each action in the AWS Management Console so you are never guessing whether a command succeeded
  • Not sure which AWS path fits your current skills? Get a straight answer at finder.platformproof.com

Why the IAM CLI Matters Even When the Console Exists

The AWS Management Console is a great tool for learning, but every professional AWS workflow eventually moves toward the CLI, infrastructure as code, or both. When you are managing dozens of users across multiple AWS accounts, clicking through console menus for each one is slow and error-prone. The CLI makes IAM actions repeatable, scriptable, and audit-friendly. A shell script that creates a standard set of users, assigns them to the right groups, and generates their initial access keys is something you can run identically in dev, staging, and production.

For certification purposes, understanding the CLI commands deepens your understanding of how IAM actually works. When you type aws iam create-user and see the response JSON, you are reading the same data structures that appear in CloudTrail logs and in the IAM API documentation. That recognition pays off when an exam question describes an API call and asks what it does or what permissions are required to run it.

Setting Up: Cloud9 as Your AWS CLI Playground

The tutorial uses AWS Cloud9, which is a browser-based IDE that comes pre-configured with an IAM role attached to the underlying EC2 instance. That means you get AWS CLI access without manually configuring credentials. When you open a terminal inside Cloud9, you are already authenticated with the permissions granted to the Cloud9 instance’s IAM role. For learning purposes this is ideal because you skip the step of running aws configure and dealing with your first set of keys before you have even learned what keys are.

If you are following along outside of Cloud9, you need to have the AWS CLI installed and configured with credentials that have IAM administrative permissions. The command aws configure walks you through entering your access key ID, secret access key, default region, and default output format. Once that is done, every command shown here will work the same way in any terminal.

Step 1: Create an IAM User With aws iam create-user

The first command in the tutorial creates a new IAM user named Alex. The full command is:

aws iam create-user –user-name Alex

When this runs successfully, AWS returns a JSON object with the user’s details. You will see the creation date in UTC format, the user ID which is a unique identifier that starts with AIDA, and the ARN which stands for Amazon Resource Name. The ARN follows the pattern arn:aws:iam::ACCOUNT_ID:user/Alex. The account ID is specific to your AWS account and the path component at the end confirms the resource type and name.

After running the command, the tutorial switches over to the AWS Management Console and clicks refresh in the IAM Users section. The user Alex appears immediately at the top of the list. This side-by-side verification pattern is worth adopting in your own practice. Seeing the console update in real time after a CLI command confirms the command ran correctly and helps you build the mental map between CLI output and console state that you need for exam questions.

At this point Alex exists in IAM but has no password, no access keys, no group membership, and no policies. He could not log in to the console or make any API calls. An IAM user without any attached permissions or group memberships can authenticate if given credentials but AWS will deny every API call they attempt. Creating the user is only the first step in provisioning a functional identity.

Step 2: Set a Console Login Password With aws iam create-login-profile

An IAM user without a login profile cannot log in to the AWS Management Console. The login profile is what ties a password to the user account. The command to create one is:

aws iam create-login-profile –user-name Alex –password July04

In the tutorial, the date was used as a placeholder password. In a real account you would want a password that meets your account’s password policy, which can require a minimum length, uppercase letters, lowercase letters, numbers, and symbols. AWS lets administrators enforce these requirements through IAM account password policies. A simple date string as a password would fail that policy in most production accounts.

After running the command, the tutorial goes back to the IAM console, clicks on the user Alex, and refreshes the page. Under the Security credentials tab, the Console password field now shows Enabled where it previously showed None. The manage password option in the console lets administrators reset, disable, or require a password change at next sign-in. These console actions correspond to CLI commands like aws iam update-login-profile for changing the password and aws iam delete-login-profile for removing console access entirely.

The tutorial notes that the change sometimes takes about 30 seconds to appear. In practice, IAM changes are usually near-instant but AWS documentation notes that IAM is eventually consistent across its global infrastructure. If a change does not appear immediately, a page refresh typically resolves it.

Step 3: Generate Access Keys With aws iam create-access-key

Console access lets a human log in through a browser. Programmatic access, the kind used by applications, scripts, and the AWS CLI itself, requires access keys. Each access key is a pair: an access key ID that starts with AKIA and a secret access key which is a longer random string. The command to generate them is:

aws iam create-access-key –user-name Alex

The response JSON contains both the access key ID and the secret access key in plain text. This is the only time AWS will ever show you the secret access key. Once you close this terminal session or leave the page, you cannot retrieve the secret again. The tutorial is explicit about this: if you lose the secret access key, you cannot recover it. Your only option is to delete the existing key and create a new one.

The console provides a Download CSV button during key creation that saves both values to a file. In scripted environments you would capture the CLI output and store it securely, such as in AWS Secrets Manager or a parameter store, rather than leaving it in shell history. Treating access keys like passwords, rotating them regularly, and never committing them to source code are baseline security hygiene practices that every AWS certification exam expects you to know.

The Hard Limit: Two Access Keys Per IAM User

AWS allows a maximum of two active or inactive access keys per IAM user. The tutorial demonstrates this by running aws iam create-access-key –user-name Alex a second time, which succeeds and produces a second key pair. At that point, the Security credentials tab in the console shows two keys listed and the Create access key button is grayed out with a tooltip that says Limit exceeded.

Then the tutorial tries a third time from the CLI. AWS returns an error: LimitExceeded: Cannot exceed quota for AccessKeysPerUser: 2. This is worth knowing for exams and for real work. The two-key limit exists so that you can rotate a key without locking out a running application. The rotation pattern is: create the new key, update your application to use the new key, verify the application works, then delete the old key. At no point does the application lose access because both keys are valid during the rotation window.

If you need to create a third key and you are already at the limit, you must first delete one of the existing two. The console delete button and the CLI command aws iam delete-access-key –user-name Alex –access-key-id AKIAIOSFODNN7EXAMPLE both accomplish this. The limit also applies to inactive keys, meaning a key you have deactivated but not deleted still counts against the quota.

Not sure which AWS service or certification track fits where you are right now?

Answer a few quick questions and get a straight recommendation at finder.platformproof.com.

Step 4: Add the User to an IAM Group With aws iam add-user-to-group

At this point Alex has a console password and two access keys. But he still has no permissions. Every AWS API call he attempts will return an Access Denied error. The tutorial has a pre-existing group called HR that already has a policy attached. To add Alex to that group the command is:

aws iam add-user-to-group –group-name HR –user-name Alex

This command returns no output on success, which is common in Unix-style CLI tools. Silence means the operation completed without error. To verify, the tutorial navigates to the IAM console, goes to the Groups section on the left, clicks HR, and confirms that Alex now appears alongside another user in the group membership list.

The HR group in the tutorial has a single policy attached: AWS OpsWorks Full Access. That policy grants permissions to every OpsWorks API action. Alex can now use OpsWorks and nothing else. Any attempt to use EC2, S3, RDS, or any other service will still return Access Denied. This is the principle of least privilege in action: a user gets exactly the permissions they need for their role, no more.

Groups vs. Per-User Policies: The IAM Best Practice

The tutorial closes with a point that the AWS certification exams test repeatedly: managing permissions through groups is better than attaching policies directly to individual users. The reason becomes clear when you think about scale. If your company has 50 developers and you need to grant them all read access to S3, you could attach an S3 read policy to each of those 50 user accounts individually. But then if the S3 bucket naming convention changes and the policy needs to be updated, you have 50 policy updates to make.

With groups, you attach the policy to the Developers group once. All 50 users are in that group. When the policy changes, you update it in one place. When a new developer joins, you add them to the group and they immediately have the right permissions. When someone leaves or changes roles, you remove them from the group or move them to a different group. The policy itself never needs to change.

AWS certification exam questions regularly present scenarios where a company is struggling to manage permissions at scale and ask you to recommend a solution. The answer is almost always to consolidate permissions into groups and use role-based access control rather than per-user policy assignments. The hands-on demonstration in this tutorial makes that abstract concept concrete.

Honest Drawbacks: What This 2018 Tutorial Does Not Cover

This tutorial is a foundational exercise, not a complete IAM security guide. A few gaps worth knowing about before you build a real production identity setup:

No MFA enforcement. The tutorial creates a user with a simple date as a password and no multi-factor authentication. In any real account, you should require MFA for all users, especially those with console access. AWS provides an IAM policy condition that denies all API calls except MFA enrollment until the user has registered a device.

No password policy. The account in the tutorial did not appear to have a password complexity policy set. AWS lets you enforce minimum length, required character types, password expiration, and prohibition of password reuse at the account level. Setting this policy ensures that every user in the account, regardless of how they were created, must use a password that meets your security requirements.

IAM roles are often better than IAM users for applications. The tutorial creates an IAM user with access keys for programmatic access. This works, but for applications running inside AWS, IAM roles are the preferred approach. A role attached to an EC2 instance or a Lambda function provides temporary credentials that AWS rotates automatically. You never have to store, rotate, or worry about leaking a static access key. The tutorial author was using Cloud9 with an attached role, which is exactly this pattern, but the explicit lesson about when to use roles versus users did not make it into the video.

Groups do not nest. IAM groups cannot contain other groups. You cannot create a parent group called Engineering and a child group called Backend and have the Backend group inherit Engineering’s policies. Each user must be added to each group individually. This is an IAM limitation that surprises people coming from directory services like Active Directory where nested groups are common.

The Full Setup: A Step-by-Step Playbook

Here is the complete sequence of commands demonstrated in the tutorial, in order, with a note on what each one does:

  • aws iam create-user –user-name Alex creates the IAM user; returns user ID, ARN, and creation date
  • aws iam create-login-profile –user-name Alex –password [YOURPASSWORD] sets a console login password so the user can access the AWS Management Console
  • aws iam create-access-key –user-name Alex generates an access key ID and secret access key; save the output immediately because the secret is shown only once
  • Run aws iam create-access-key a second time to demonstrate the two-key limit; the console Create access key button grays out after this
  • Try a third time to see the LimitExceeded error from the CLI
  • aws iam add-user-to-group –group-name HR –user-name Alex places Alex in the HR group; Alex now inherits all policies attached to that group
  • Verify in the console under IAM > Groups > HR > Users tab that Alex appears alongside the other group members

Find Your X

AWS IAM is one layer of a larger cloud career or business picture. If you are trying to figure out which AWS service, certification track, or online income path actually fits your situation right now, the Platform Proof Finder asks you a few targeted questions and gives you a straight recommendation. No fluff, no upsell, just a direction based on where you are.

Frequently Asked Questions

What is the difference between an IAM user and an IAM role?

An IAM user is a permanent identity with long-term credentials: a console password and access keys. An IAM role is a temporary identity that can be assumed by a user, an AWS service, or an application. Roles issue short-term credentials that expire automatically. For applications running inside AWS, roles are the recommended approach because there are no static keys to manage or rotate.

Why can’t I see the secret access key after I close the terminal?

AWS shows the secret access key exactly once, at the moment of creation, because AWS does not store the secret in a retrievable form after that initial display. This is a security design decision. If you lose the secret, delete the existing access key with aws iam delete-access-key and generate a new one.

What happens if I hit the two-access-key limit?

The CLI returns a LimitExceeded error with the message “Cannot exceed quota for AccessKeysPerUser: 2”. The console grays out the Create access key button. To create a new key, you must first delete one of the existing two. The delete operation accepts the access key ID as a parameter, so you do not need to know the secret to delete the key.

Can I create an IAM user without the CLI, using a different method?

Yes. The AWS Management Console provides a wizard for creating users. The AWS CloudFormation resource AWS::IAM::User creates users as part of a stack. Terraform uses the aws_iam_user resource. The AWS SDK supports the CreateUser API call in every supported language. The CLI commands in this tutorial correspond directly to those underlying API calls.

How do I verify which groups a user belongs to?

Run aws iam list-groups-for-user –user-name Alex from the CLI. This returns a list of all groups the user is a member of, including the group name, group ID, ARN, and path. In the console, click the user in the IAM Users list and look at the Groups tab.

What permissions does a user in a group actually have?

A group member inherits all the permissions granted by policies attached to the group. The tutorial’s HR group had a single policy, AWS OpsWorks Full Access, attached. That meant Alex could perform any OpsWorks action and nothing else. A user can belong to multiple groups and their effective permissions are the union of all policies from all groups they belong to, plus any policies attached directly to the user, plus any permissions from assumed roles.

Is Cloud9 required to follow these exercises?

No. Cloud9 was the presenter’s preferred environment because it comes with AWS CLI access pre-configured via an attached IAM role. Any terminal with the AWS CLI installed and credentials configured through aws configure will work. That includes your local machine, an EC2 instance, AWS CloudShell which is available directly in the console, or any CI/CD runner with AWS credentials injected as environment variables.

Are these IAM CLI exercises still relevant in 2024?

Yes. The commands demonstrated in this 2018 tutorial, create-user, create-login-profile, create-access-key, and add-user-to-group, are part of the stable IAM API and have not changed. AWS is known for long-term API stability. The two-access-key limit, the one-time secret access key display, and the group inheritance model all work exactly the same way today as they did when this video was recorded. What has changed is the surrounding best-practice guidance: roles over long-term keys, MFA everywhere, and identity center for multi-account organizations.

Read Next

If you want to keep building on your AWS CLI fundamentals, the next logical step is working with other AWS services from the command line.

Check out AWS DynamoDB Tutorial via the Console for a hands-on walkthrough of setting up a database, creating tables, and reading and writing items, the same side-by-side CLI and console verification style applied to a fully managed NoSQL database.

Sources

  • Original YouTube tutorial: https://youtu.be/dPQKRn9Ok-s
  • AWS IAM CLI reference: aws iam create-user, create-login-profile, create-access-key, add-user-to-group
  • AWS documentation: IAM Access Key Limits (2 per user)
  • AWS documentation: IAM Best Practices (groups over per-user policies)
  • AWS Cloud9 IDE: browser-based development environment with pre-configured AWS credentials

Related Reading


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