Imagine you are building a massively multiplayer online game (MMO). In your game, thousands or more users may be playing at the same time, and your architecture must handle the load. As part of your application, you have an inventory system. Players can find, purchase, sell, and trade items, and you need to store this information in a database.

In this lab, you learn how to use Amazon Aurora Serverless to handle the inventory system in your application. You also learn how to provision and configure an Amazon Aurora Serverless database and the related infrastructure to build your inventory system as a web service.

In Module 1, you configure your environment and download the code that you use during the lab.

Time to Complete Module: 20 Minutes

 


  • Step 1: Create an AWS account

    Use a personal AWS account or create a new AWS account for this lab. Do not use an organizational account so that you have full access to the necessary services and do not leave behind any resources from the lab. If you do not delete the resources used in this lab when you are finished, you may incur AWS charges.

  • Step 2: Set up your AWS Cloud9 IDE

    AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug code with just a browser. AWS Cloud9 includes a code editor, debugger, and terminal. It also comes prepackaged with essential tools for popular programming languages and the AWS Command Line Interface (CLI) preinstalled so that you don’t have to install files or configure your laptop for this lab. Your AWS Cloud9 environment will have access to the same AWS resources as the user with which you signed in to the AWS Management Console.

    To set up your AWS Cloud9 development environment:

    1. Navigate to the AWS Management Console, choose Services at the top of the page, and then choose Cloud9 under Developer Tools.
    2. Choose Create environment.
    3. Type Serverless Aurora Inventory in the Name box. Leave the Description box empty.
    4. Choose Next step.
    5. Leave the Environment settings at their defaults to create a new t2.micro EC2 instance, which will be hibernated after 30 minutes of inactivity.
    6. Choose Next step.
    7. Review the environment name and settings, and choose Create environment. Your environment will be provisioned and prepared after several minutes.
    8. When the environment is ready, your IDE should open with a welcome note.

    You should now see your AWS Cloud9 environment. You need to be familiar with the three areas of the AWS Cloud9 console shown in the following screenshot:

    • File explorer: On the left side of the IDE, the file explorer shows a list of the files in your directory.
    • File editor: On the upper right area of the IDE, the file editor is where you view and edit files that you’ve selected in the file explorer.
    • Terminal: On the lower right area of the IDE, this is where you run commands to execute code samples.
    inv-sys-mod1-step2

    (Click to enlarge)

    inv-sys-mod1-step2
  • Step 3: Download the supporting code

    In this lab, you use Javascript to interact with your Amazon Aurora Serverless database and with other AWS services. Run the following commands in your AWS Cloud9 terminal to download and unpack the module code.

    cd ~/environment
    curl -sL http://d118jxrmrxsq90.cloudfront.net/inventory.tar | tar -xv

    Run the following command in your AWS Cloud9 terminal to view your directories.

    ls

    You should see two directories in the AWS Cloud9 file explorer:

    • application: The application directory contains example code for the inventory application. This code is similar to the code you would have in your real inventory application backend.
    • scripts: The scripts directory contains administrator-level scripts, such as for creating AWS resources or loading data into your database.

    Run the following command in your AWS Cloud9 terminal to install the dependencies for both directories.

    npm install --prefix scripts/ && npm install --prefix application

    Run the following command in your AWS Cloud9 terminal to set your AWS Region in an environment file. This example uses us-east-1, but enter your AWS Region of choice to use for the lab.

    echo "export AWS_REGION=us-east-1" >> env.sh && source env.sh

    You use the env.sh file to store environment variables of resources and other parameters you need in this lab. If you take a break during this lab and then start a new session in your AWS Cloud9 environment, be sure to reload your environment variables by executing the following command in your terminal:

    source env.sh

In this module, you learned about the example application you build in this lab. You also set up an AWS account and configured an AWS Cloud9 instance.

You are now ready to start the lab. In the next module, you provision your Amazon Aurora Serverless database.