Giter VIP home page Giter VIP logo

terraform-microservices-example's Introduction

terraform-microservices-example

This project is a simple example of using Terraform to deploy two microservices to AWS (GCP coming soon!) that can communicate with each other via service discovery. The two microservices are a frontend webserver (using Next.js) and a backend API server (using Flask). You can use any framework/libraries you want for these microservices, what's provided here is just a starting point!

Installation

AWS

  • Ensure you have installed: Terraform, Docker, and Docker Compose.
  • Clone this repo.
  • Sign up for AWS if you haven't already.
  • Create a repository called fe in ECR repository console: https://[YOUR-REGION].console.aws.amazon.com/ecr/create-repository
  • Create a repository called api in ECR repository console: https://[YOUR-REGION].console.aws.amazon.com/ecr/create-repository
  • Copy repository hostname: [YOUR_DOCKER_REPO_ID].dkr.ecr.[YOUR-REGION].amazonaws.com
  • Set the copied repository hostname to TF_VAR_docker_repo in your terminal.
  • In your terminal, run: export TF_VAR_docker_repo=[YOUR_DOCKER_REPO_ID]
  • In your terminal, run: aws ecr get-login-password --region [YOUR-REGION] | docker login --username AWS --password-stdin [YOUR_DOCKER_REPO_ID].dkr.ecr.us-west-2.amazonaws.com

Usage

Deploy

./deploy.sh

Terraform will show you a load balancer URL when it has finished deploying. Wait about 60 seconds before visiting this as it can take time for all of the resources to come online. When it does, you should see "Data from API server route /api/foo: bar" in your browser.

Undeploy

./destroy.sh

Local Development

./dev.sh

Visit http://localhost:3000 to see the frontend server running!

Architecture Diagram

Coming soon!

Credits

Basic Terraform setup: https://github.com/bradford-hamilton/terraform-ecs-fargate

terraform-microservices-example's People

Contributors

farsabbutt avatar ryanmcdermott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

terraform-microservices-example's Issues

Feedback/Question

Hey, thanks for putting this out, really appreciate!

I have a question on same lines, I also do almost similar what you have done. What is the approach you suggest if we have to add a new backend microservice in the project?

Currently in the project I am working on we have around 20 backend microservices and I created one terraform module and having 20 tf files which calls the module with different values in those 20 tf files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.