Skip to content

druids/terraform-aws-ecs-app

Repository files navigation

ECS App (EC2)

This module creates resources for a containarized ECS application.

EC2

This is a version for EC2 backed ECS cluster.

The service is behind a load balancer which means it is exposed. A HTTP healthcheck is required.

Required resources

  • ECS cluster
  • VPC
  • VPC subnets
  • Application Load Balancer (ALB)

Creates resources

  • ECS service
  • ECS task definition
  • Container definition (using Cloudposse module)
  • ECR repository
  • IAM task execution role
  • Custom policy attachment
  • CloudWatch log group
  • Security group
  • ALB target group
  • ALB listener rule

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
aws n/a

Inputs

Name Description Type Default Required
alb_arn application load balancer under which target group and services will be registered any n/a yes
app app name any n/a yes
cluster_name ecs cluster name where the services will be registered any n/a yes
cooldown n/a number 60 no
cpu CPU reservation for the task number 256 no
deregistration_delay n/a number 30 no
environment n/a list [] no
healthcheck_grace n/a number 0 no
healthcheck_healthy_threshold n/a number 3 no
healthcheck_interval n/a number 60 no
healthcheck_matcher n/a string "200" no
healthcheck_path n/a string "/" no
healthcheck_timeout n/a number 5 no
healthcheck_unhealthy_threshold n/a number 3 no
image override image - disables creating ecr repository string "" no
load_balancing_algorithm_type n/a string "least_outstanding_requests" no
log_retention for how many days to keep app logs number 30 no
max_capacity n/a number 1 no
max_healthy n/a number 200 no
memory MEM reservation for the task number 256 no
memory_limit MEM hard limit for the task number 0 no
min_capacity n/a number 1 no
min_healthy n/a number 50 no
name name of this specific service any n/a yes
placement_constraint_expression n/a string "agentConnected==true" no
placement_constraint_type n/a string "memberOf" no
policy IAM Policy heredoc to use with task string "" no
port port on which the service listens number 80 no
priority listener rule priority - must be unique to each ecs-app (module) any n/a yes
private_subnet_ids list of private subnets where to provision services list n/a yes
project project name any n/a yes
scale_down n/a number 30 no
scale_up n/a number 80 no
scheduling_strategy n/a string "REPLICA" no
secrets n/a list [] no
stage stage name any n/a yes
tags n/a map {} no
url url for the alb listener any n/a yes
vpc_id vpc id - used in target group, security group etc any n/a yes

Outputs

Name Description
cloudwatch_log_group_arn n/a
ecr_repository n/a