Merge pull request #3829 from hashicorp/b-aws-ecs-cluster-read

provider/aws: Fix issue that could occur if no ECS Cluster was found for a give name
This commit is contained in:
Clint 2015-11-10 16:43:42 -06:00
commit 9e93f655e2
1 changed files with 9 additions and 2 deletions

View File

@ -59,9 +59,16 @@ func resourceAwsEcsClusterRead(d *schema.ResourceData, meta interface{}) error {
}
log.Printf("[DEBUG] Received ECS clusters: %s", out.Clusters)
d.SetId(*out.Clusters[0].ClusterArn)
d.Set("name", *out.Clusters[0].ClusterName)
for _, c := range out.Clusters {
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
}