   (->>
    (reservations)
    (mapcat :instances)
-   (map bean)))
+   (map bean)
+   (filter #(not= :terminated (-?> % :state (bean) :name (keyword))))))
   
 (defn all-instance-ids []
   (map :instanceId (instances)))


(defn delete-keypair
  [name]
  (println "deleting keypair %s" name)
  (with-ec2-client client
    (-> client
        (.deleteKeyPair (DeleteKeyPairRequest. name)))))

(defn delete-keypairs-matching [re]
  (doseq [kp (filter #(re-find re (:keyName %)) (keypairs))]
    (delete-keypair (-> kp :keyName))))
(ns circle.backend.ec2
  (:use [circle.aws-credentials :only (aws-credentials)])
  (:use [clojure.tools.logging :only (infof)])
  (:use [clojure.core.incubator :only (-?>)])
  (:import com.amazonaws.services.ec2.AmazonEC2Client
           (com.amazonaws.services.ec2.model DescribeInstancesResult
                                             TerminateInstancesRequest
