func terminateInstances(c *C, e *ec2.EC2, insts []*ec2.Instance) { var ids []string for _, inst := range insts { if inst != nil { ids = append(ids, inst.InstanceId) } } _, err := e.TerminateInstances(ids) c.Check(err, IsNil, Commentf("%d INSTANCES LEFT RUNNING!!!", len(ids))) }