/terraform-aws-ecs-fargate-1

Minimal ECS Fargate Service Module 🐙

Primary LanguageHCLDo What The F*ck You Want To Public LicenseWTFPL

ECS FARGATE

Terraform

Description

This is Minimal ECS Fargate Service Module. These types of resources are supported:

Type

Load Balancer

type = lb is create target group and connect to ecs_service.

Private Service Discovery

type = sd is create private service discovery and connect to ecs_service.

Nothing

type = no is not create more resources.

Auto Scalling

is_mem_scale = true or is_cpu_scale = true

Usage

module "fargate" {
  source              = "grandcolline/ecs-fargate/aws"
  version             = "1.2.0"
  service_name        = "FargateTestService"
  cluster_name        = aws_ecs_cluster.main.name
  task_definition_arn = aws_ecs_task_definition.main.arn
  container_name      = "ecs_demo_app"
  assign_public_ip    = true
  type                = "lb"
  service_subnets     = ["${var.service_subnet_id}"]
  lb_dns              = aws_alb.main.dns_name
}

Inputs

Common Variables

Name Description Type Default Required
add_tags Additional tags map(string) {} no

Fargate Variables

Name Description Type Default Required
service_name fargate service name string n/a yes
cluster_name ECS cluster name string n/a yes
task_count task's desired count & minimum capacity string "1" no
task_definition_arn task definition's arn string n/a yes
type fargate service type. load balancer or service discovery or nothing (lb/sd/no) string "no" no
deployment_maximum_percent maximum percent when deploy number 200 no
deployment_minimum_healthy_percent minimum percent when deploy number 50 no
assign_public_ip assign public ip to the task bool "false" no

Network Variables

Name Description Type Default Required
service_subnets List of subnet id's to put the task on list n/a yes

Load Balancer Variables (type = lb)

Name Description Type Default Required
container_name container's name to which target group connect string "" no
container_port container's port to which target group connect string "8080" no
deregistration_delay time for load balancing to wait before deregistering a target number 300 no
lb_dns load balancer's dns string "" no
healthy_threshold number 2 no
unhealthy_threshold number 5 no
healthcheck_timeout number 5 no
healthcheck_protocol string "HTTP" no
healthcheck_path string "/hc" no
healthcheck_interval number 30 no
healthcheck_matcher number 200 no

Service Discovery Variables (type = sd)

Name Description Type Default Required
dns_namespace_id string "" no
dns_ttl number 10 no

Auto Scalling Variables

Name Description Type Default Required
task_max_count task's maximum capacity number 2 no
is_mem_scale scale task by memory usage bool "false" no
mem_target_value target value of scale task by memory usage (%) number 40 no
mem_scale_in_cooldown cool down time of scale in task by memory usage number 300 no
mem_scale_out_cooldown cool down time of scale out task by memory usage number 300 no
is_cpu_scale scale task by cpu usage bool "false" no
cpu_target_value target value of scale task by cpu usage (%) number 40 no
cpu_scale_in_cooldown cool down time of scale in task by cpu usage number 300 no
cpu_scale_out_cooldown cool down time of scale out task by cpu usage number 300 no

Outputs

Name Description
target_group_arn target group's arn
target_group_arn_suffix target group's arn suffix