Terraform, AWS ECS, Github Actions, clustering, and more DevOps fun!

TLDR

This repo got all Terraform IaC files to setup AWS ECS for Elixir apps that includes web server(s) and database. It includes auto deployment with Github Actions, and shows how to deal with exposing multiple ports and blue-green deployment strategy.

https://github.com/danschultzer/elixir-terraform-aws-ecs-example

Background

AWS is an insane timesink. There are only few articles that detail full Terraform setups and all were missing different pieces that I needed to have a full production setup. I spend so much time trying to understand how to setup infrastructure properly and deploy to ECS. To save others from this pain I’ve put it all together in a repo detailing step by step with git commits how to set up an Elixir project with Terraform code for continuous delivery.

In our company we use it for umbrella projects with multiple Phoenix apps. Unfortunately AWS is very microservice happy so it’s not an ideal setup with multiple task files and deployment steps. But it works!

Furthermore I’ve enabled CI testing of this repo using LocalStack simulating AWS. So you can be sure that the IaC files in the repo actually works.

I’ve also tried to set up logic that creates a phoenix app from scratch and deploys it right there in Github Actions validating that it connects to db and other nodes :exploding_head: Unfortunately LocalStack has a bunch of issues around this so won’t work for a while.

I’ll keep updating the the repo as I learn from dealing with AWS. Let me know what you think!

19 Likes

This is awesome!

woot lots to learn!