provider/aws: making the target_group_arn optional for the ecs_service hash func
This commit is contained in:
parent
aac87bf875
commit
ee9c84cf7f
|
@ -511,21 +511,14 @@ func resourceAwsEcsLoadBalancerHash(v interface{}) int {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
m := v.(map[string]interface{})
|
m := v.(map[string]interface{})
|
||||||
|
|
||||||
// There are 2 types of load balancers: ELB/ALB
|
buf.WriteString(fmt.Sprintf("%s-", m["elb_name"].(string)))
|
||||||
// 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["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)))
|
||||||
|
|
||||||
|
if s := m["target_group_arn"].(string); s != "" {
|
||||||
|
buf.WriteString(fmt.Sprintf("%s-", s))
|
||||||
|
}
|
||||||
|
|
||||||
return hashcode.String(buf.String())
|
return hashcode.String(buf.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue