Get in touch
or send us a question?
CONTACT

Install the Amplify CLI

Install the Amplify CLI

The Amplify Command Line Interface (CLI) is a unified toolchain to create AWS cloud services for your app. Let’s go ahead and install the Amplify CLI.NPMcURL (Mac and Linux)cURL (Windows)

npm install -g @aws-amplify/clicopy

Resolve EACCES permissions when installing packages globally with npm

Pre-requisites for installation

  • Install Node.js® and NPM if they are not already on your machine.
  • Verify that you are running at least Node.js version 12.x and npm version 6.x or greater by running node -v and npm -v in a terminal/console window
  • Create AWS Account. If you don’t already have an AWS account, you’ll need to create one in order to follow the steps outlined in this tutorial.

Configure the Amplify CLI

To set up the Amplify CLI on your local machine, you have to configure it to connect to your AWS account.

If you already have an AWS profile with credentials on your machine, you can skip this step.

If you are using CLI version < 10.8.0 go to Configure CLI < 10.8.0

Configure Amplify by running the following command:

amplify configurecopy

amplify configure will ask you to sign into the AWS Console.

Once you’re signed in, Amplify CLI will ask you to create an IAM user.

Amazon IAM (Identity and Access Management) enables you to manage users and user permissions in AWS. You can learn more about Amazon IAM here.

Specify the AWS Region
? region:  # Your preferred region
Follow the instructions at
https://docs.amplify.aws/cli/start/install/#configure-the-amplify-cli

to complete the user creation in the AWS console
https://console.aws.amazon.com/iamv2/home#/users/create

Navigate to the IAM User creation page if it’s not already open.

Enter a User name and select Next. You can name the user anything but we’ll call it “amplify-dev”.

image

Select Attach policies directly and select AdministratorAccess-Amplify as the Permissions policy. Select Next.

image

On the Review page, check that everything looks good and select Create user.

image

This will redirect to the users list page. Select the user you just created.

image

On the user details page, navigate to the Security credentials tab, scroll down to Access keys and select Create access keys.

image

On the next page, select Command Line Interface, acknowledge the warning, and select Next.

image

On the next page select Create access key. You’ll then see a page with the access keys for the user. Use the copy icon to copy these values to your clipboard, then return to the Amplify CLI.

image

Enter the values you just copied into the corresponding CLI prompts.

Enter the access key of the newly created user:
? accessKeyId:  # YOUR_ACCESS_KEY_ID
? secretAccessKey:  # YOUR_SECRET_ACCESS_KEY
This would update/create the AWS Profile in your local machine
? Profile Name:  # (default)

Successfully set up the new user.

Configure the Amplify CLI version < 10.8.0Option 1: Watch the video guide

Watch the video below to learn how to install and configure the Amplify CLI or skip to the next section to follow the step-by-step instructions.https://www.youtube-nocookie.com/embed/fWbM5DLh25UOption 2: Follow the instructions

Configure Amplify by running the following command:

amplify configurecopy

amplify configure will ask you to sign into the AWS Console.

Once you’re signed in, Amplify CLI will ask you to create an IAM user.

Amazon IAM (Identity and Access Management) enables you to manage users and user permissions in AWS. You can learn more about Amazon IAM here.

Specify the AWS Region
? region:  # Your preferred region
Specify the username of the new IAM user:
? user name:  # User name for Amplify IAM user
Complete the user creation using the AWS console

Create a user with AdministratorAccess-Amplify to your account to provision AWS resources for you like AppSync, Cognito etc.

image

Once the user is created, Amplify CLI will ask you to provide the accessKeyId and the secretAccessKey to connect Amplify CLI with your newly created IAM user.

Enter the access key of the newly created user:
? accessKeyId:  # YOUR_ACCESS_KEY_ID
? secretAccessKey:  # YOUR_SECRET_ACCESS_KEY
This would update/create the AWS Profile in your local machine
? Profile Name:  # (default)

Successfully set up the new user.

It is recommended to create a new IAM user for every device that installs the Amplify CLI, rather than attempt to use an existing IAM user used on another device. Having a distinct user for each machine provides the best level of visibility and control without breaking the deployment of your app, allowing for the quick deactivation of an individual machine if needed.

Work within your frontend project

After you install the CLI, navigate to a JavaScript, iOS, or Android project root, initialize AWS Amplify in the new directory by running amplify init. After a few configuration questions, you can use amplify help at any time to see the overall command structure. When you’re ready to add a feature, run amplify add <category>.