diff --git a/main.tf b/main.tf index 9a5178a8..fbe02b33 100644 --- a/main.tf +++ b/main.tf @@ -19,30 +19,31 @@ resource "aws_cloudwatch_log_group" "app" { } module "alb_ingress" { - source = "git::https://github.com/cloudposse/terraform-aws-alb-ingress.git?ref=tags/0.3.0" + source = "git::https://github.com/cloudposse/terraform-aws-alb-ingress.git?ref=tags/0.3.1" name = "${var.name}" namespace = "${var.namespace}" stage = "${var.stage}" attributes = "${var.attributes}" vpc_id = "${var.vpc_id}" - listener_arns = ["${var.listener_arns}"] + listener_arns = "${var.listener_arns}" listener_arns_count = "${var.listener_arns_count}" health_check_path = "${var.alb_ingress_healthcheck_path}" paths = ["${var.alb_ingress_paths}"] priority = "${var.alb_ingress_listener_priority}" hosts = ["${var.alb_ingress_hosts}"] + port = "${var.container_port}" } module "container_definition" { - source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.2.0" + source = "git::https://github.com/cloudposse/terraform-aws-ecs-container-definition.git?ref=tags/0.3.0" container_name = "${module.default_label.id}" container_image = "${var.container_image}" container_memory = "${var.container_memory}" container_memory_reservation = "${var.container_memory_reservation}" container_cpu = "${var.container_cpu}" - container_port = "${var.container_port}" healthcheck = "${var.healthcheck}" environment = "${var.environment}" + port_mappings = "${var.port_mappings}" log_options = { "awslogs-region" = "${var.aws_logs_region}" @@ -52,7 +53,7 @@ module "container_definition" { } module "ecs_alb_service_task" { - source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.5.0" + source = "git::https://github.com/cloudposse/terraform-aws-ecs-alb-service-task.git?ref=tags/0.6.0" name = "${var.name}" namespace = "${var.namespace}" stage = "${var.stage}" @@ -68,6 +69,7 @@ module "ecs_alb_service_task" { vpc_id = "${var.vpc_id}" security_group_ids = ["${var.ecs_security_group_ids}"] private_subnet_ids = ["${var.ecs_private_subnet_ids}"] + container_port = "${var.container_port}" } module "ecs_codepipeline" { diff --git a/outputs.tf b/outputs.tf index 71736760..74ed666a 100644 --- a/outputs.tf +++ b/outputs.tf @@ -17,3 +17,8 @@ output "task_role_arn" { description = "ECS Task role ARN" value = "${module.ecs_alb_service_task.task_role_arn}" } + +output "service_security_group_id" { + description = "Security Group id of the ECS task" + value = "${module.ecs_alb_service_task.service_security_group_id}" +} diff --git a/variables.tf b/variables.tf index f30a8d01..0c22453f 100644 --- a/variables.tf +++ b/variables.tf @@ -67,6 +67,17 @@ variable "container_port" { default = "80" } +variable "port_mappings" { + type = "list" + description = "The port mappings to configure for the container. This is a list of maps. Each map should contain \"containerPort\", \"hostPort\", and \"protocol\", where \"protocol\" is one of \"tcp\" or \"udp\". If using containers in a task with the awsvpc or host network mode, the hostPort can either be left blank or set to the same value as the containerPort." + + default = [{ + "containerPort" = 80 + "hostPort" = 80 + "protocol" = "tcp" + }] +} + variable "desired_count" { type = "string" description = "The desired number of tasks to start with. Set this to 0 if using DAEMON Service type. (FARGATE does not suppoert DAEMON Service type)" @@ -103,6 +114,12 @@ variable "healthcheck" { default = {} } +variable "alb_target_group_arn" { + type = "string" + description = "Pass target group down to module" + default = "" +} + variable "alb_target_group_alarms_enabled" { type = "string" description = "A boolean to enable/disable CloudWatch Alarms for ALB Target metrics."