Building microservices using Terraform, Ansible, Docker, Docker Compose, and Github Actions

Click for: original source

This blog post explores the benefits of microservices in building a scalable and maintainable application. By Wamaitha.

Infrastructure as code(IAC) is a methodology for deploying, configuring, and managing servers. Typically when you need to host your application on the internet, you create VMs on hosting providers like Linode, Vultr, DigitalOcean, AWS, or GCP. Once the VMs are up, you either SSH directly into the instance or use a CICD workflow to get your application running on the VM. Using IAC tools, we can automate this process. This guide will cover Terraform, Ansible, Docker, and GitHub Actions to build microservices.

The content of the article covers:

  • Tools used
  • Project Overview
  • Prerequisites
  • Installations
  • Microservices
    • Dad Jokes as a service.
    • Kanye as a service
    • MongoDB as a service
    • My Jokes Microservice
    • React Microservice
    • Run all the microservices
  • Provisioning VM with Terraform
  • Automating deploys with Ansible
  • Using Github Actions as the Controller Machine

The final step runs the ansible playbook, passing the private key stored in the SSH_PRIVATE_KEY secret as an argument to the –private-key flag. This step also reads the secrets stored in the repository and appends them to the .env file in the microservices directory. Finally, the ansible-playbook command is run to execute the playbook. Nice one!

[Read More]

Tags devops ansible app-development cloud