Skip to content

Commit

Permalink
Merge pull request #3829 from hashicorp/b-aws-ecs-cluster-read
Browse files Browse the repository at this point in the history
provider/aws: Fix issue that could occur if no ECS Cluster was found for a give name
  • Loading branch information
catsby committed Nov 10, 2015
2 parents de4d35c + 2694022 commit 9e93f65
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions builtin/providers/aws/resource_aws_ecs_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9e93f65

Please sign in to comment.