From e9d7d427759eeaee21f61688afb38af705e5730b Mon Sep 17 00:00:00 2001 From: KensoDev Date: Mon, 3 Apr 2017 20:57:42 -0700 Subject: [PATCH] fix integration between ALB and ECS For our ECS service definition we have this snippet at the `load_balancer`. The `target_group_arn` is being pupulated by an external service that returns the arn based on a simple string from our microservices list. If the arn changed, this would not cause a recreation of the service and leaving a dangling pointer to an arn that does not exist anymore. ``` load_balancer { target_group_arn = "${lookup(var.target_group_mapping, element(values(var.microservices), count.index))}" container_name = "${element(values(var.microservices), count.index)}" container_port = "${var.container_port}" } ``` The fix is adding another field to the set that's creating the ELB/ALB definition. From looking into the git history seems this code was created prior to ALB thus not having this field available at the time. Service is being recreated as expected, no other services are affected (expected behavior) --- builtin/providers/aws/resource_aws_ecs_service.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/providers/aws/resource_aws_ecs_service.go b/builtin/providers/aws/resource_aws_ecs_service.go index 80d2d44a1..eb6f10ad2 100644 --- a/builtin/providers/aws/resource_aws_ecs_service.go +++ b/builtin/providers/aws/resource_aws_ecs_service.go @@ -510,6 +510,8 @@ func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error func resourceAwsEcsLoadBalancerHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) + + buf.WriteString(fmt.Sprintf("%s-", m["target_group_arn"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["elb_name"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["container_name"].(string))) buf.WriteString(fmt.Sprintf("%d-", m["container_port"].(int)))