0
0
AwsHow-ToBeginner · 4 min read

How to Create an IAM User in AWS: Step-by-Step Guide

To create an IAM user in AWS, use the AWS Management Console or AWS CLI by specifying the user name and permissions. The user can be assigned programmatic access, console access, or both using aws iam create-user command or the console wizard.
📐

Syntax

The basic syntax to create an IAM user using AWS CLI is:

  • aws iam create-user --user-name <UserName>: Creates a new IAM user with the specified name.
  • Additional commands assign permissions or access keys.
bash
aws iam create-user --user-name NewUserName
Output
An IAM user named 'NewUserName' is created successfully.
💻

Example

This example shows how to create an IAM user named developer1 with programmatic access and attach a policy for read-only access to S3.

bash
aws iam create-user --user-name developer1
aws iam create-access-key --user-name developer1
aws iam attach-user-policy --user-name developer1 --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
Output
User 'developer1' created. Access key created for 'developer1'. Policy 'AmazonS3ReadOnlyAccess' attached to 'developer1'.
⚠️

Common Pitfalls

Common mistakes when creating IAM users include:

  • Not assigning permissions, leaving the user unable to do anything.
  • Creating users without programmatic or console access when needed.
  • Using overly broad permissions instead of least privilege.

Always attach only the necessary policies and verify access.

bash
aws iam create-user --user-name testuser
# Wrong: No permissions attached, user cannot access resources

aws iam attach-user-policy --user-name testuser --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
# Right: Attach only needed policies, avoid AdministratorAccess unless necessary
📊

Quick Reference

Summary tips for creating IAM users:

  • Use descriptive user names.
  • Grant least privilege permissions.
  • Create access keys only if programmatic access is needed.
  • Use groups to manage permissions for multiple users.
  • Regularly review and rotate access keys.

Key Takeaways

Create IAM users with clear names using AWS CLI or Console.
Always assign appropriate permissions to enable user tasks.
Use least privilege principle to enhance security.
Generate access keys only if programmatic access is required.
Manage permissions efficiently using groups and policies.