 (def lambda-cli! (partial aws-cli! "lambda"))
 
 (def fn-config-args
-  #{:name :role :handler :description :timeout :memory-size :runtime :vpc})
+  #{:name :role :handler :description :timeout :memory-size :runtime :vpc :dead-letter})
+
+(def fn-spec-defaults
+  {:vpc {:subnets [] :security-groups []} :dead-letter ""})
 
 (def create-function-args
   (into fn-config-args
     #{:zip-file :output :query}))
 
 (def update-function-code-args
-  (remove #{:vpc} create-function-args))
+  (remove #{:vpc :dead-letter} create-function-args))
 
 (defn validate-fn-spec! [{fn-name :name vpc :vpc}]
   (let [subnets (:subnets vpc)

(defn- update-function-config! [fn-spec]
  (lambda-cli!
   :update-function-configuration
   (-> (merge {:vpc {:subnets [] :security-groups []}} fn-spec)
       (select-keys fn-config-args)
       ->cli-args)))


      (update-in [:vpc :security-groups] sort)))

(defn remote-config->local-config [remote]
  (let [remote (set/rename-keys remote {:function-name :name :vpc-config :vpc :dead-letter-config :dead-letter})]
    (merge
      remote
      (if-let [vpc (:vpc remote)]
        (assoc remote :vpc
          (-> vpc
              (select-keys #{:subnet-ids :security-group-ids})
              (set/rename-keys {:subnet-ids :subnets :security-group-ids :security-groups}))))
      {:dead-letter (get-in remote [:dead-letter :target-arn] "")})))

(defn same-config? [remote local]
  (let [remote (-> remote remote-config->local-config normalize-config)
        local  (-> (merge fn-spec-defaults local) (select-keys fn-config-args) normalize-config)]
    (= (select-keys remote (keys local)) local)))

(defn- deploy-function!
