Workshop Component Architecture

Deploying the API

This workshop consists of two web applications and a back-end API. The web applications are run locally while the API is run out of AWS. To get started, we must deploy the API using the Serverless Application Model (SAM) CLI.

  1. In a terminal in the root directory of the code repository, navigate to the api directory by typing in the following command:
cd api
  1. Run the following commands:
sam build --parallel
sam deploy --guided

NOTE - The above commands will deploy to the default profile configured via the AWS CLI. If you wish to deploy with a specific profile, you can use the following commands.

sam build --parallel
sam deploy --guided --profile <profilename>
  1. Complete the wizard in the terminal, filling out values appropriately. Recommended values are below. If you should need to redeploy for any reason, you need not provide the “–guided” parameter and will not need to answer the questions again.
Argument Recommended Value
Stack Name momento-pizza-app
AWS Region use default
MomentoApiToken use token obtained from setup step
Confirm changes before deploy N
Allow SAM CLI IAM role creation Y
Disable rollback N
All “no auth defined” prompts Y
Save arguments to configuration file Y
SAM configuration file samconfig.toml
SAM configuration environment default
  1. The stack will deploy into your AWS account. On completion, you will see two outputs provided in the terminal: Outputs from deployment
  2. Copy the value from the AdminApiEndpoint and open the file ./admin-ui/next.config.js (from the root directory).
  3. Update the NEXT_PUBLIC_ADMIN_API property with the copied value.
const nextConfig = {
  env: {
    NEXT_PUBLIC_ADMIN_API: '<copied value from output>'
  }
}

module.exports = nextConfig
  1. Copy the deployment output value OrderApiEndpoint and open the file ./order-ui/next.config.js (from the root directory).
  2. Update the NEXT_PUBLIC_ORDER_API property with the copied value.

That’s it! You’re setup and we are ready to start!