GithubHelp home page GithubHelp logo

coaktion / terraform-aws-ecs-fargate-module Goto Github PK

View Code? Open in Web Editor NEW

This project forked from inaciogu/terraform-aws-ecs-fargate-deployment

0.0 0.0 0.0 45 KB

JavaScript 1.03% HCL 98.46% Dockerfile 0.51%

terraform-aws-ecs-fargate-module's Introduction

ECS Fargate terraform module

This module creates the full ECS Fargate setup, including the push of the docker image to ECR using your Dockerfile.

Usage

module "ecs-fargate" {
  source                = "github.com/inaciogu/terraform-aws-ecs-fargate-deployment"
  aws_access_key_id     = "test"
  aws_secret_access_key = "test"
  aws_region            = "us-east-1"
  account_id            = "00000000000"

  vpc_cidr_block             = "10.0.0.0/16"
  public_subnet_cidr_blocks  = ["10.0.1.0/24", "10.0.2.0/24"]
  private_subnet_cidr_blocks = ["10.0.4.0/24", "10.0.5.0/24"]
  security_group_name        = "example-security-group"

  clusters = [{
    name = "example-cluster"
    services = [{
      desired_count = 1
      name          = "example-service"
      task_definition = {
        cpu         = 1024
        memory      = 2048
        family_name = "example-task"
        container_definitions = [
          {
            name                = "example-container"
            repository_name     = "example-repository"
            dockerfile_location = "."
            portMappings = [{
              containerPort = 80
              hostPort      = 80
              protocol      = "tcp"
            }]
            environment = [
              {
                name  = "EXAMPLE_ENVIRONMENT_VARIABLE"
                value = "example-value"
              }
            ]
          },
        ]
      }
    }]
  }]
}

Secrets Manager integration

If you want to use secrets from Secrets Manager, you can use the secret_manager property in the container_definitions. The values stored in the secret will be set as secrets inside the container, and will be available as environment variables.

container_definitions = [
  {
    name                = "example-container"
    repository_name     = "example-repository"
    dockerfile_location = "."
    portMappings = [{
      containerPort = 80
      hostPort      = 80
      protocol      = "tcp"
    }]
    secret_manager = "example-secret-name"
  },
]

Network

You can use existing subnets and security groups by setting the network object inside the service or create the vpc configuration from scratch using the variables vpc_cidr_block, public_subnet_cidr_blocks, private_subnet_cidr_blocks and security_group_name.

Existing network setup:

services = [{
  name = "example-service"
  network = {
    subnets_tags = {
			key = "project"
			value= "example-subnet"
		}
    security_groups_tags = {
			key = "project"
			value = "example-security-group"
		}
  }
}]

New network setup:

vpc_cidr_block             = "10.0.0.0/16"
public_subnet_cidr_blocks  = ["10.0.1.0/24", "10.0.2.0/24"]
private_subnet_cidr_blocks = ["10.0.3.0/24", "10.0.4.0/24"]
security_group_name        = "example-security-group"

Note: Currently, the module supports just one vpc creation thats why the vpc variables are not inside the service object.

terraform-aws-ecs-fargate-module's People

Contributors

inaciogu avatar paulo-tinoco 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.