   (:require [circle.backend.ssh])
   (:import com.amazonaws.services.ec2.AmazonEC2Client
            com.amazonaws.AmazonServiceException
-           (com.amazonaws.services.ec2.model DeleteKeyPairRequest
+           (com.amazonaws.services.ec2.model CreateImageRequest
+                                             DeleteKeyPairRequest
                                              DeleteSecurityGroupRequest
                                              DescribeImagesRequest
                                              DescribeInstancesRequest

                                                       (.getGroupName g))))
               (assoc :tags (into {} (for [t (map bean (-> inst :tags))] [(:key t) (:value t)]))))))
       (table [:instanceId :state-name :publicIpAddress :imageId :security-groups :tags])
       (println)))
  (with-ec2-client client
    (-> client
        (.describeImages (-> (DescribeImagesRequest.) (.withImageIds [ami]))))))

(defn image-state [ami]
  (-> (describe-image ami)
      (bean)
      :images
      (first)
      (bean)
      :state
      (keyword)))

(defn block-until-running
  "Blocks until AWS claims the instance is running"
