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)
This commit is contained in:
KensoDev 2017-04-03 20:57:42 -07:00
parent b1fd1c0ba3
commit e9d7d42775
1 changed files with 2 additions and 0 deletions

View File

@ -510,6 +510,8 @@ func resourceAwsEcsServiceDelete(d *schema.ResourceData, meta interface{}) error
func resourceAwsEcsLoadBalancerHash(v interface{}) int { func resourceAwsEcsLoadBalancerHash(v interface{}) int {
var buf bytes.Buffer var buf bytes.Buffer
m := v.(map[string]interface{}) 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["elb_name"].(string)))
buf.WriteString(fmt.Sprintf("%s-", m["container_name"].(string))) buf.WriteString(fmt.Sprintf("%s-", m["container_name"].(string)))
buf.WriteString(fmt.Sprintf("%d-", m["container_port"].(int))) buf.WriteString(fmt.Sprintf("%d-", m["container_port"].(int)))