Giter Club home page Giter Club logo

sample-terraform's Introduction

Dockerized App to AWS ECS with Terraform

This is NOT a tutorial on how to deploy an app to AWS ECS with Terraform. This is a simple example of how to use Docker, Terraform, and AWS ECS to deploy a simple app.

This is mailny for my own reference, but if you find it useful, feel free to use it.

Tools

  • Terraform (well actually Tofu)
  • aws dynamo
  • aws S3

Description

I wanted to deploy an app to AWS ECS using Terraform. I found a lot of tutorials on how to do this, but I wanted to do it my way. I wanted to use Docker, Terraform, and AWS ECS to deploy a simple app.

I wanted to see how I manage terraform state, how I manage secrets, and how I manage the deployment of the app. So I decide to have terraform state on S3 and dynamoDB.

So I have terraform to build my S3 and dynamoDB, and then I have terraform to build my ECS cluster, and then I have terraform to build my app.

Build Terraform state S3 and DynamoDB

View "terraform-backend" folder, it contains the definitions for a new s3 bucket and dynamoDB table to store the terraform state.

On paper this is a one-time thing, but I was playing around with it, so I had to destroy and recreate it a few times.

steps:

  • got to the "terraform-backend" folder
  • run terraform init
  • run terraform plan
  • run terraform apply
  • run terraform destroy (when you want to remove it in the end)

*** verify if S3 bucket deletion actually works, as I needed to manually empty the items before I could have deleted the bucket.

Build the App

This one create all the needed items to deploy the app to AWS ECS. VPC, subnets, security groups, ECS cluster, ECS service, ECS task definition, and the app itself.

The outputs is used for me to get the load balancer url in the end.

steps:

  • got to the "terraform-app" folder
  • run terraform init -backend-config=backend-config.hcl
  • run terraform plan
  • run terraform apply
  • run terraform destroy (when you want to remove it in the end)

side notes

I used tofu instead of terraform. Just replace terraform with tofu in the commands above.

sample-terraform's People

Contributors

tzookb avatar

Watchers

 avatar

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.