Fix a panic that could occur if no ECS Cluster was found for a given cluster name
This commit is contained in:
parent
deb17b90eb
commit
2694022b4a
|
@ -59,9 +59,16 @@ func resourceAwsEcsClusterRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
}
|
}
|
||||||
log.Printf("[DEBUG] Received ECS clusters: %s", out.Clusters)
|
log.Printf("[DEBUG] Received ECS clusters: %s", out.Clusters)
|
||||||
|
|
||||||
d.SetId(*out.Clusters[0].ClusterArn)
|
for _, c := range out.Clusters {
|
||||||
d.Set("name", *out.Clusters[0].ClusterName)
|
if *c.ClusterName == clusterName {
|
||||||
|
d.SetId(*c.ClusterArn)
|
||||||
|
d.Set("name", c.ClusterName)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("[ERR] No matching ECS Cluster found for (%s)", d.Id())
|
||||||
|
d.SetId("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue