Environment Setup

Environment Setup

  1. Open the environment folder
  • In the VSCode web interface, first open the ~/environment folder via the menu:

vscfile

vscfile

Click on I trust the author in the next dialog.

vscfile

  1. Download the Mythical Mysfits Workshop Repository to the environment
  • Open the terminal via the menu or the keyboard shortcut Ctrl + Shift + C

vscfile

  • In the command line interface, run the following command:
git clone https://github.com/Hieu192/amazon-ecs-mythicalmysfits-workshop.git

Set up

  1. After cloning the repository, change the directory path:
cd amazon-ecs-mythicalmysfits-workshop/workshop-1

Set up

  1. We execute the following command to install the environment in preparation for the lab.
script/setup
  • This script will remove unnecessary Docker images to free up space.
  • It also populates the DynamoDB table with original data.
  • Uploads the web content to S3.
  • Installs some authentication mechanisms related to Docker.
#! /bin/bash

set -eu

echo "Removing unneeded docker images..."
docker images -q | xargs docker rmi || true

echo "Installing dependencies..."
sudo yum install -y jq

echo "Fetching CloudFormation outputs..."
script/fetch-outputs

echo "Populating DynamoDB table..."
script/load-ddb

echo "Uploading static site to S3..."
if [[ $# -eq 1 ]]; then
  script/upload-site $1
else
  script/upload-site
fi

echo "Installing ECR Cred Helper..."
sudo script/credhelper

echo "Success!"

Set up

  1. When you see “Success!” displayed on the interface, the command has executed successfully. (remember Ctrl + C to exit) Set up Set up

  2. Check in the S3 interface

  • The website files have been uploaded in the bucket

Set up

  1. Check in the DynamoDB interface
  • The original data has been populated in the DynamoDB Table

Set up

  1. We should configure the aws cli with our current region as default:
export ACCOUNT_ID=$(aws sts get-caller-identity --output text --query Account)
export TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
export AWS_REGION=$(curl -H "X-aws-ec2-metadata-token: $TOKEN" -s 169.254.169.254/latest/dynamic/instance-identity/document | jq -r '.region')

echo "export ACCOUNT_ID=${ACCOUNT_ID}" >> ~/.bash_profile
echo "export AWS_REGION=${AWS_REGION}" >> ~/.bash_profile
aws configure set default.region ${AWS_REGION}
aws configure get default.region

Set up