Code Monkey home page Code Monkey logo

terraform-ecs's Introduction

Deploy application in ECS Fargate

  • We will be able to run one command to deploy our entire application giving us:

    • A Virtual Private Cloud with private and public subnets
    • Internet Gateway and NatGateway
    • Multiple running container instances
    • A load balancer distributing traffic between the containers
    • Auto scaling of your resources
    • Health checks and logs

To get internet traffic to containers using a load balancer, the load balancer is placed into a public subnet. ECS configures the load balancer to forward traffic to the container tasks in the private subnet: alt text

This configuration allows your tasks in Fargate to be safely isolated from the rest of the internet. They can still initiate network communication with external resources via the NAT gateway, and still receive traffic from the public via the Application Load Balancer that is in the public subnet.

  • All configurations can be changed in:
variables.ft

You can choose your docker image application to deploy in Fargate, changing app_image and app_port in variables.tf

variable "az_count" {
  description = "Number of AZs to cover in a given region"
  default     = "2"
}

variable "app_image" {
  description = "Docker image to run in the ECS cluster"
  default     = "gcr.io/google-samples/hello-app:2.0"
}
  1. Terraform init, plan and validate scripts
terraform init
terraform plan
terraform validate
  1. Apply changes
terraform apply

Output console: Plan: 34 to add, 0 to change, 0 to destroy.

Before to create all resources you can access to application with

curl -v http:/<LOAD_BALANCER_HOSTNAME>/
  1. Remember to destroy all resources to avoid incurring payments
terraform destroy -auto-approve

terraform-ecs's People

Contributors

carlospreventor avatar

Watchers

 avatar  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.