Install & Configs

We recommended to run this workshop on local environment. If you have difficulty setting up Node.js or npm in your local environment, you can use AWS Cloud9, which is the cloud-based integrated development environment (IDE) provided by AWS. For more information, see 10.1. Set up AWS Cloud9. However, for Amplify Mocking, port 20002 must be available and may not be available in some Cloud IDEs. Please understand in advance.

If you are familiar with Docker and Visual Studio Code, you can use Visual Studio Code’s Remote Container; aws-amplify-sns-workshop-in-vscode instead of using local environment. If you use this, you can skip “Installing Node.js/npm”, “Installing Java” and “Installing Amplify CLI” in this section.

Before you start coding, you should install, update, and configure some software.

Installing Node.js/npm

The Amplify CLI recommends 10.x for Node.js and 6.x or later versions for npm. This section confirms that the recommended version of Amplify is installed in your environment. Only those who need to install Node.js/npm are required to perform the installation procedure.

  1. In order to check the version, execute the following command in Terminal.

    node -v; npm -v
    # The following is an example of the execution result.
    v12.16.1 #<- Node.js version
    6.13.4 #<- npm version
    
  2. If you are using Node.js 10.x or later, please proceed to the next section.

  3. If you are using a version earlier than Node.js 10.x, or if you do not have Node.js installed, you can follow the steps below to install or update Node.js.

  4. Make sure that the installation is finished.

    node -v; npm -v
    

npm, a package management tool, is installed automatically when you install Node.js

Installing Java

Amplify Mocking requires the Java runtime since OpenJDK 1.8. This section makes sure that the version of Java required by Amplify Mocking is installed in your environment. Only those who need to install Java are required to perform the Java installation procedure.

  1. Verifying the Java version

    java -version
    # The following is an example of the execution result.
    openjdk version "1.8.0_232"
    OpenJDK Runtime Environment Corretto-8.232.09.1 (build 1.8.0_232-b09)
    OpenJDK 64-Bit Server VM Corretto-8.232.09.1 (build 25.232-b09, mixed mode)
    
  2. If you are using OpenJDK 1.8 or later, please proceed to the next section.

  3. If you are using OpenJDK 1.7 or earlier, or if you do not have Java installed, you can follow the steps below to install or update Java. In this workshop, you use Amazon Corretto, which is the free, production-ready OpenJDK Distribution provided by AWS.

  4. Make sure that the installation is finished.

    java -version
    

If the package management tool brew is installed on macOS, it can be installed with $ brew cask install corretto.

Installing Amplify CLI

To install the Amplfiy CLI, execute the following command in Terminal.

# Install the AWS Amplify CLI
npm install -g @aws-amplify/cli@4.16.1

If you are already using Amplify CLI, please reinstall it according to the version specified.

Configuring Amplify CLI

This workshop builds the backend using Amplify CLI. You create an IAM user and set credentials to allow Amplify CLI to connect to the backend.

amplify configure

When you execute the amplify configure command, you see “Sign in to your AWS administrator account:”

You may be prompted to log in as the root user, but you do not need to be the root user. Log in as an IAM user who can create an IAM user with the privileges required by Amplify.

Press Enter and you are prompted for the Region or IAM user name to use. Select us-east-1 for the Region, and all others specify the default.

A URL is issued starting with https://console.aws.amazon.com/iam/~~, and you are able to access it in another browser.

If the URL is not issued, please access here.

Follow the navigation of the screen to create an IAM user. You do not need to change any choices or settings.

If you do not want to create an IAM user with Admin privileges, please visit 10.3 IAM Policy and create an IAM policy.

  1. Create a user create iam user
  2. Attach IAM policies attach policy
  3. Add tagas (option)
  4. Review settings confirm
  5. Complete user creation (Please do not close this screen!) confirm

Return to Terminal and press Enter. Access Key ID and Secret Access Key ID are asked to enter. Please copy those IDs that appear on the IAM User Creation Complete screen in your browser.
You can leave Profile Name as the default (default), but for later clarity, we recommend you to use amplify-handson here.

inputcredentials.jpg

Please make sure that “Successfully set up the new user.” is appeared on the console. You can now issue commands from Amplify CLI with the privileges of the IAM user you created.

If AWS CLI is installed, you can also check the Profile created with the following command. (If not installed, you do not need to check it.)

aws sts get-caller-identity —profile amplify-handson
{
  "UserId": "XXXXXXXXXXXXXXXX",
  "Account": "YYYYYYYYYYYYYYYYY",
  "Arn": "arn:aws:iam። YYYYYYYYYYYYYY:user/amplify-ZZZZZ"
}