Skip to content

Instantly share code, notes, and snippets.

@leikahing
Created February 21, 2018 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leikahing/a1847186e5090fef482b505a173d3ca4 to your computer and use it in GitHub Desktop.
Save leikahing/a1847186e5090fef482b505a173d3ca4 to your computer and use it in GitHub Desktop.
A really quick Clojure program that validates the existence of files in S3
(ns migratool.core
(:gen-class)
(:require [clojure.string :as string]
[amazonica.core :refer :all]
[amazonica.aws.s3 :as s3]
[com.climate.claypoole :as cp]))
(def access-key "")
(def secret-key "")
(def bucket "")
(def creds {:access-key access-key :secret-key secret-key :endpoint ""})
(defn verify-object [object-name]
(let [exists (s3/does-object-exist creds bucket object-name)]
(cond (false? exists) (do (println object-name) "")
:else "")))
(defn check-files [files region]
(cp/with-shutdown! [net-pool (cp/threadpool 40)]
(def rsps (cp/upmap net-pool verify-object files))
(doall rsps)))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(let [contents (string/split-lines (slurp ""))]
(do
(check-files contents "ap-northeast-1"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment