Overview
In this lab, we will build infrastructure as code and deploy into a DevOps style Ci/Cd stream.
Prerequisites
- A basic understanding of AWS services like EC2 and ECS is a plus
- A basic understanding of the principals of Docker and Continuous
- Integration servers will be helpful
What to bring
- Laptop with a web browser (an installed VNC viewer would be helpful)
- A mouse might be helpful for fast copy/pasting
- An AWS Free Tier account aws.amazon.com/free (ideally, one account per concurrent lab users and no production resources deployed)
- A free travis-ci.org account and
- A free github.com account in your name
What we’ll build
- We will build a very simple Flask / Python application, not unlike the version we created in the Flask Lambda Lab
- But this lab has much less focus on the application, and much more focus on using Docker to build and deploy applications into the AWS Cloud.
- We will use terraform to build a secure and fault tolerant and scalable application infrastructure in AWS ECS. We will use terraform.io to deploy a separate VPC, 4 subnets, Application Load Balancers, Auto Scaling Groups and an AWS ECS Docker Cluster.
- We’ll use github for version control. We’ll fork a project into your personal github repository and make a few changes to the application and commit the changes to the github repository.
- We will use travis-ci as our Continuous Integration Server. Every time we commit code to github, travis will use the .travis.yml file in the root of our project to build and test our application. For this lab we’ll run one very simple test that checks the validity of all the links. If the build and test succeeds, and if our code was committed with a tag (i.e. v1.0) then Travis will push our Docker image to the AWS ECR repository.
- From there, when we are ready, we can put the tested docker Containers into production using a deploy.sh script.
Lesson 2 – Build a Developer workstation
We’ll start by launching a Linux Desktop in AWS EC2 that we’ll use for
- the developer’s workstation. Normally, the developer would use her
- local PC for writing code, but in this lab downloading & configuring the tools
- on the Laptop would take more time than we have. Instead, we built a nice
- little Ubuntu Linux Workstation AMI that has everything already setup. A VNC
- server, docker, docker-compose, atom IDE, AWS CLI, git, travis CLI, terraform,
- the jq json parser and a few other bits already installed. Additionally, when
- running a desktop in AWS, we are not constrained by CPU power, available disk
- space, available memory or our bandwidth for downloads. We will connect to this
- developer workstation via a VNC client on your web browser, or a thick VNC
- client that you download to your laptop. The Desktop experience with the
- thick VNC client is much better.
Then, we will fork the Flask application repository, link it to the travis-ci
- service and clone it to the developer workstation. We’ll use docker-compose to
- build a local docker container to run our application and we’ll test local
- access to the app, just like a developer would do on his desktop. We’ll use
- the Atom ide to make some changes, make sure they look good on the local host.
Lesson 3 – Infrastructure as Code and Continuous Integration
- We’ll use terraform.io to build the AWS infrastructure described in the figure above.
- While that is running, we’ll commit our application changes to github
- If things work correctly, travis-ci will be notified of the commit and will start a build of the environment. If the tests pass, it will push a brand new docker image to AWS ECR artifact repository.
- We’ll test the application is running and access the application access through a web browser
- To make additional changes, just update the local code library, commit to github, validate the build went correctly, then deploy the production code
Lesson 4 – Cleanup
- Finally, we’ll destroy all the resources that we created, including the developer workstation
Up Next
In Lesson 2, Lets build that Developer Workstation
Recent Comments