How to create an AWS IAM User with the CLI

How to create an AWS IAM User with the CLI

To create a new user in your AWS account, you can use the create-user CLI command.

In the terminal, enter the following to create an IAM user named Bob in the current account:

aws iam create-user  --user-name Bob

Output:

{
  "User": {
        "UserName": "Bob",
        "Path": "/",
        "CreateDate": "2013-06-08T03:20:41.270Z",
        "UserId": "AIDAIOSFODNN7EXAMPLE",
        "Arn": "arn:aws:iam::123456789012:user/Bob"
    }
}

The create-user command accepts additional options. The --user-name option is required.

create-user
  --user-name <value> //required
  --path <value> //optional
  --permissions-boundary <value> //optional
  --tags <value> //optional
  --cli-input-json | --cli-input-yaml //optional
  --generate-cli-skeleton <value> //optional
  --cli-auto-prompt <value> //optional

For more information about the command and the additional options, see create-user in the official AWS CLI Command reference.

Note: For this example to work, you need to install and configure the AWS CLI first.