Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanmcdermott/terraform-microservices-example
Using Terraform to deploy microservices that communicate with each other
https://github.com/ryanmcdermott/terraform-microservices-example
docker ecr ecs microservices terraform
Last synced: 17 days ago
JSON representation
Using Terraform to deploy microservices that communicate with each other
- Host: GitHub
- URL: https://github.com/ryanmcdermott/terraform-microservices-example
- Owner: ryanmcdermott
- License: mit
- Created: 2020-08-15T19:41:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-15T04:44:19.000Z (over 2 years ago)
- Last Synced: 2024-10-19T04:12:06.912Z (19 days ago)
- Topics: docker, ecr, ecs, microservices, terraform
- Language: HCL
- Homepage:
- Size: 89.8 KB
- Stars: 23
- Watchers: 3
- Forks: 13
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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