Skip to content

Commit

Permalink
Merge branch 'master' into add-stop-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mikael-lindstrom authored Dec 12, 2019
2 parents 5873470 + 835f8e6 commit 35e16b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,21 @@ resource "aws_ecs_service" "service" {
launch_type = "FARGATE"
deployment_minimum_healthy_percent = var.deployment_minimum_healthy_percent
deployment_maximum_percent = var.deployment_maximum_percent
health_check_grace_period_seconds = var.health_check_grace_period_seconds
health_check_grace_period_seconds = var.lb_arn == "" ? null : var.health_check_grace_period_seconds

network_configuration {
subnets = var.private_subnet_ids
security_groups = [aws_security_group.ecs_service.id]
assign_public_ip = var.task_container_assign_public_ip
}

load_balancer {
container_name = var.container_name != "" ? var.container_name : var.name_prefix
container_port = var.task_container_port
target_group_arn = aws_lb_target_group.task.arn
dynamic "load_balancer" {
for_each = var.lb_arn == "" ? [] : [1]
content {
container_name = var.container_name != "" ? var.container_name : var.name_prefix
container_port = var.task_container_port
target_group_arn = aws_lb_target_group.task.arn
}
}

deployment_controller {
Expand All @@ -205,10 +208,8 @@ resource "aws_ecs_service" "service" {
# HACK: The workaround used in ecs/service does not work for some reason in this module, this fixes the following error:
# "The target group with targetGroupArn arn:aws:elasticloadbalancing:... does not have an associated load balancer."
# see https://github.com/hashicorp/terraform/issues/12634.
# https://github.com/terraform-providers/terraform-provider-aws/issues/3495
# Service depends on this resources which prevents it from being created until the LB is ready
resource "null_resource" "lb_exists" {
triggers = {
alb_name = var.lb_arn
}
triggers = var.lb_arn == "" ? {} : { alb_name = var.lb_arn }
}

1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ variable "task_container_image" {
}

variable "lb_arn" {
default = ""
description = "Arn for the LB for which the service should be attach to."
type = string
}
Expand Down

0 comments on commit 35e16b6

Please sign in to comment.