Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Terraform Working Example

Whenever I need to setup a project to automatically be deployed through Terraform, it almost always revolves around a core of deploying a "Dockerized" web service on EC2 instances.

I have finally created my own little starter/template project on GitHub to make life easier when creating a new project. It's goal is to get you up and running quickly and easily, with a structure and enough comments/documentation to show you how you can easily tweak the configuration, and choose from one of the two deployment strategies it contains which are:

  • Simple deployment - one EC2 server with the Docker container
  • Advanced deployment using multiple EC2 servers that run the containers, but these EC2 instances are deployed by an auto scaling service, which is pointed to by an elastic load balancer.

The advanced setup has the advantage of allowing you to easily scale up/down your web service by just setting the number of instances, and if any instances webserver were to become unresponsive, it automatically gets replaced.

I created a little youtube video (below) to demonstrate that it works, and how easy it is.

Taking It Further

Last updated: 2nd February 2024
First published: 18th June 2021