thomasni91 / hello-world-terraform

A terraform project to deploy a simple nodejs based hello-world app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pre-requisite

Setup

  1. Apply the remote_state terraform project. This will create s3 bucket and lock table for keeping remote state for other tf projects.
cd infra/accounts/dev/remote_state; terraform apply
  1. Apply the ecs terraform project.
cd infra/accounts/dev/ecs; terraform apply

This will output

  • URL to access the web server.
  • ECR repo url where docker images should be pushed.

Development

  1. Make desired code changes to src directory.
  2. Run docker build
cd src; docker build -t <docker_ecr_repo_url>:<version> .
  1. Docker login into the ECR repo
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <ecr_repo_url>
  1. Publish docker image
docker push <docker_ecr_repo_url>:<version>
  1. Apply the ecs terraform project with the version provided in above step
cd infra/accounts/dev/ecs; terraform apply -var="release_version=<release_version>"

TODO

  • Use terragrunt for making terraform code DRY in case new env is added.

About

A terraform project to deploy a simple nodejs based hello-world app.


Languages

Language:HCL 95.8%Language:JavaScript 2.4%Language:Dockerfile 1.8%