Deploy a Node Express app onto Amazon ECS on AWS Fargate
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
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
Create a Github project, and generate a personal access token (see doc here)
Create an S3 bucket to store Terraform state. Populate bucket name in 01-main.tf
Create a secret on AWS Secrets Manager named DockerHubAccessToken
with key DOCKER_HUB_ACCESS_TOKEN
, and your Docker access token as value
Create a secret on AWS Secrets Manager named MongoPassword
with key MONGO_PASSWORD
, and your MongoDB password as value
Populate terraform.tfvars
:
default_region = "us-east-1"
docker_username = "matlau"
github_username = "MatthewCYLau"
github_project_name = "node-aws-fargate-terraform"
app_name = "node-aws-fargate-app"
environment = "production"
mongo_username = "admin-matlau"
mongo_host = "mattewcylau-5ltcp.mongodb.net"
mongo_database_name = "node-aws-fargate-app"
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
When prompted for github_token
, provide the value and hit Return. Alternatively, create a local environment variable named TF_VAR_github_token
POST
request to /api/users
with the following JSON body:{
"email": "[email protected]",
"password": "password",
"name": "jondoe"
}
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 :star: or even better buy me a coffee :coffee: :point_down: because I'm a caffeine addict :sweat_smile: