     (do ~@body) 
     (throw+ {:type ::aws:missing-id :message "Instance id not found"}))) 
 
+(defn creation-keys [aws]
+  (clojure.set/subset? (into #{} (keys aws))
+    #{:volumes :min-count :max-count :instance-type :key-name}))
+
 (defn create-instance 
    "creates instance from aws" 
    [{:keys [aws machine] :as spec} endpoint]
-   {:pre [(clojure.set/subset? (into #{} (keys aws))
-       #{:volumes :min-count :max-count :instance-type :key-name})]}
+   {:pre [(creation-keys aws)]}
    (let [inst (merge (dissoc aws :volumes) {:image-id (image-id machine)})]
-     (-> (with-ctx ec2/run-instances inst) :instances first :id)))
+     (get-in (with-ctx ec2/run-instances inst) [:instances 0 :instance-id])))
 
 (defconstrainedrecord Instance [endpoint spec user]
   "An Ec2 instance"

    (with-instance-id
      (debug "deleting" instance-id)
      (delete-volumes endpoint instance-id (spec :system-id)) 
      (with-ctx ec2/terminate-instances instance-id) 
      (wait-for-status this "terminated" [5 :minute])
      ; for reload support
      (s/update-system (spec :system-id) 


(ns aws.provider
  (:require 
    [amazonica.aws.ec2 :as ec2]
    [aws.common :refer (with-ctx instance-desc creds image-id)]
    [aws.networking :refer (update-ip set-hostname pub-dns)]
    [aws.volumes :refer (delete-volumes handle-volumes)]
    [aws.sdk.eip :as eip]
    [aws.validations :refer (provider-validation)]
    [celestial.persistency :as p]
