provider/aws: making the target_group_arn optional for the ecs_service hash func

This commit is contained in:
stack72 2017-04-10 16:00:18 +03:00
parent aac87bf875
commit ee9c84cf7f
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
1 changed files with 5 additions and 12 deletions

View File

@ -511,21 +511,14 @@ func resourceAwsEcsLoadBalancerHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
// There are 2 types of load balancers: ELB/ALB
// In case of ELB `elb_name` is expected and for ALB `target_group_arn` is.
optionalLoadBalancerParams := []string{"target_group_arn", "elb_name"}
for i := range optionalLoadBalancerParams {
paramName := optionalLoadBalancerParams[i]
if m[paramName] != nil {
buf.WriteString(fmt.Sprintf("%s-", m[paramName].(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)))
if s := m["target_group_arn"].(string); s != "" {
buf.WriteString(fmt.Sprintf("%s-", s))
}
return hashcode.String(buf.String())
}