Chapter 1

By the end of this course, you will have deployed a set of microservices, powered by Flask and React, to Amazon Elastic Container Service (ECS).

More specifically, we'll:

  1. Configure CodeBuild to run when code is checked in to GitHub
  2. Run unit and integrations tests and check code for quality and formatting issues on CodeBuild
  3. Package the microservices as Docker images
  4. Push the images to Amazon Elastic Container Registry (ECR)
  5. Set up the appropriate ECS pieces to manage and provision EC2 boxes for deployment
  6. Configure RDS for data persistence
  7. Dump logs to CloudWatch
  8. Use the Application Load Balancer for load balancing

The two apps that you'll deploy are built using Flask and React, respectively.

Flask RESTful API

Built with Flask-RESTX, the server-side powers an API that follows RESTful design principles, using the basic HTTP verbs: GET, POST, PUT, and DELETE:

Endpoint HTTP Method CRUD Method Result
/auth/register POST CREATE register a new user
/auth/login POST CREATE log a user in
/auth/refresh POST CREATE obtain a new access token
/auth/status GET READ check user status
/users GET READ get all users
/users/:id GET READ get a single user
/users POST CREATE add a user
/users/:id PUT UPDATE update a user
/users/:id DELETE DELETE delete a user

Along with Python and Flask, SQLAlchemy is used to interact with a Postgres database and pytest is used instead of unittest for unit and integration testing. Finally, the app supports token-based authentication via the Flask-Bcrypt and PyJWT packages.

React Client

The second microservice is the client application that uses JavaScript and React. It's built with the Create React App generator and it uses Jest (a JavaScript test runner) along with React Testing Library (a testing library designed specifically for React) for unit and integration tests.

Curious about how these app were developed? Check out the Test-Driven Development with Python, Flask, and Docker and Authentication with Flask, React, and Docker courses.

Before diving in, let's take a minute to go over why some of the above tools are being used.


Flask and Django are the two most popular Python web frameworks. Django is older and more mature than Flask, but it's also more opinionated. On the other hand, Flask is lighter weight so it doesn't make many decisions for you. You get to decide how you want to implement things. At its core, Flask is simple yet extensible, which is perfect for developing RESTful APIs and microservices.

For more, review Django vs. Flask: Which Framework to Choose.


Flask-RESTX is a community-driven fork of Flask-RESTPlus that makes it easy to build and document RESTful APIs with Flask.


Docker is a container platform used to streamline application development and deployment workflows across various environments. It's used to create the infrastructure required -- like installing Linux, configuring system-level dependencies, and running Python -- for the web app within a lightweight container that can be moved from your development machine to the production server quickly and easily.


pytest is a test framework for Python that makes it easy (and fun!) to write, organize, and run tests. When compared to unittest, from the Python standard library, pytest:

  1. Requires less boilerplate code so your test suites will be more readable.
  2. Supports the plain assert statement, which is far more readable and easier to remember compared to the assertSomething methods -- like assertEquals, assertTrue, and assertContains -- in unittest.
  3. Is updated more frequently since it's not part of the Python standard library.
  4. Simplifies setting up and tearing down test state with its fixture system.
  5. Uses a functional approach.


According to the 2019 State of JavaScript Survey, React, Angular, and Vue are the three most popular front-end JavaScript frameworks. They are primarily used for developing rich single-page-applications (SPAs). React is the most popular of the three and arguably the easiest to learn.

React is technically not a framework; it's a view library. That said, when coupled with Create React App and React Router it can be considered more of a framework.

React Testing Library

As mentioned, React Testing Library (RTL) is a testing library designed specifically for React. It helps reduce the amount of boilerplate needed and provides a nice utility library, making it easier to write tests. When it comes to utility libraries, Enzyme is really your only other option. While Enzyme focuses on testing state and props, RTL focuses more on testing end user behavior. RTL has a much lower barrier to entry since it's less flexible and provides much fewer testing methods and options.


AWS is a cloud service platform that provides Infrastructure as a Service (IaaS) and Platform as a Service (PaaS) solutions. They offer compute (EC2, Elastic Beanstalk, Lambda, ECS, and Fargate), storage (S3), database (RDS, DynamoDB, and Redshift), analytics (Athena and Kinesis), application (SQS and MQ), and DevOps (CodePipeline, CodeBuild, and CodeDeploy) services.

With regard to AWS, we'll start off by configuring all services via the web console before moving to Terraform, an infrastructure as code as code solution. It's highly, highly recommended to start your AWS journey in this manner. Experiment with the web console first since it handles a lot of the complexity beneath the scenes, such as creating service roles, IAM permissions, log groups, and so on. Once you feel comfortable, jump into Terraform to learn a bit more about what's happening and to better manage the building, changing, and versioning of your infrastructure.

Mark as Completed