mjmaix / node-aws-fargate-terraform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWS Fargate Node App

A reference project to deploy a Node Express app onto Amazon ECS on AWS Fargate with Terraform, inspired by this tutorial documentation

A microservice which creates, and authenticates users from a MongoDB database

AWS Architecture

Pre-requisite

  • Make sure you have installed Terraform, AWS CLI, and configured a default AWS CLI profile (see doc here)
terraform -help # prints Terraform options
which aws # prints /usr/local/bin/aws
aws --version # prints aws-cli/2.0.36 Python/3.7.4 Darwin/18.7.0 botocore/2.0.0
aws configure # configure your AWS CLI profile
  • You have created a database on MongoDB Atlas and have obtained a database connection string

Configuration

default_region                     = "ap-southeast-1"
default_az1                        = "ap-southeast-1a"
default_az2                        = "ap-southeast-1b"
docker_username                    = "mjmaixdev"
github_full_repo_id                = "mjmaix/node-aws-fargate-terraform"
app_name                           = "mj-node-fg-aws"
environment                        = "staging"
mongo_username                     = "admin-mjmaixdev"
mongo_host                         = "iz3lksp.mongodb.net"
mongo_database_name                = "demo"
mongo_password_secret_arn          = <MongoPassword Secret ARN>
codestar_connector_credentials_arn = <Codestar Connector Credenetials ARN>

Deploy

cd deploy # change to deploy directory
terraform init # initialises Terraform
terraform apply # deploys AWS stack. See output for AWS loadbalancer DNS name
terraform destroy # destroys AWS stack

Usage

  • Create a user by making POST request to /api/users with the following JSON body:
{
  "email": "jon@doe.com",
  "password": "password",
  "name": "jondoe"
}
  • See Postman collection here

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

If you find this project helpful, please give a ⭐ or even better buy me a coffee ☕ 👇 because I'm a caffeine addict 😅

Buy Me A Coffee

License

MIT

About


Languages

Language:HCL 93.0%Language:JavaScript 5.6%Language:Smarty 1.2%Language:Makefile 0.1%Language:Dockerfile 0.1%