Break a Monolithic Application into Microservices with AWS Copilot, Amazon ECS, Docker, and AWS Fargate

TUTORIAL

Module One: Setup

Overview

In this part of the tutorial, you will install the tools required to complete the tutorial and configure your environment to access AWS services using the command line.

 Minimum time to complete

20 minutes

 Requires

  • AWS account with administrator-level access*
  • Docker
  • AWS CLI
  • AWS Copilot

*Accounts created within the past 24 hours might not yet have access to the services required for this tutorial.

Implementation

For the first part of this tutorial, you will build the Docker container image for your monolithic Node.js application and push it to Amazon Elastic Container Registry (Amazon ECR). 

Step 1: Install software

In the next few steps, you are going to be using Docker, GitHub, Amazon ECS, and Amazon ECR to deploy code into containers. To complete these steps, ensure you have the following tools.

1. An AWS account: If you don't have an account with AWS, sign up here. All the exercises in this tutorial are designed to be covered under the AWS Free Tier. Note: Some of the services you will be using may require your account to be active for more than 12 hours. If you experience difficulty with any services and have a newly created account, please wait a few hours and try again.

2. Docker: You will use Docker to build the image files that will run as containers. Docker is an open source project. You can download it for Mac or for Windows. After Docker is installed, verify it is running by entering Docker —version in the terminal. The version number should display, for example: Docker version 19.03.5, build 633a0ea.

3. AWS CLI:   

  • You will use the AWS Command Line Interface (AWS CLI) to push the images to Amazon ECR. To learn about and download the AWS CLI, see Getting started with the AWS CLI.
  • After AWS CLI is installed, verify it is running by entering aws —version in the terminal. The version number should display, for example: aws-cli/1.16.217 Python/2.7.16 Darwin/18.7.0 botocore/1.12.207.   
  • If you already have AWS CLI installed, run the following command in the terminal to ensure it is updated to the latest version: pip install awscli —upgrade —user   
  • If you have never used AWS CLI before, you may need to configure your credentials.

4. AWS Copilot: AWS Copilot is an open source command line interface that makes it easy for developers to build, release, and operate production-ready containerized applications on AWS App Runner, Amazon ECS, and AWS Fargate. On macOS, you can use brew to install AWS Copilot.

$ brew install aws/tap/copilot-cli

For other platforms, use curl or Microsoft Powershell to download the release.

Platform Command to install
macOS curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-darwin && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot —help
Linux x86 (64-bit) curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot —help
Linux (ARM) curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux-arm64 && chmod +x copilot && sudo mv copilot
Windows Invoke-WebRequest -OutFile 'C:\Program Files\copilot.exe' https://github.com/aws/copilot-cli/releases/latest/download/copilot-windows.exe

Step 2: Download and open the project

Download the code from GitHub: Navigate to this AWS Labs repository on GitHub and select Clone or Download to download the repository to your local environment. You can also use GitHub Desktop or Git to clone the repository.

Up Next: Containerize and Deploy the Monolith

Was this page helpful?