Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ So inside your `project.clj` do:
`:aws {
:access-key ~(System/getenv "AWS_ACCESS_KEY")
:secret-key ~(System/getenv "AWS_SECRET_KEY")
:endpoint "REGION-SPECIFIC ENDPOINT"
:s3-static-deploy {:bucket "THE BUCKET YOU WANT TO DEPLOY TO"
:local-root "LOCAL DIRECTORY YOU WANT TO DEPLOY FROM"}}`

The `:endpoint` keyword is only required if you want to connect to
a region-specific endpoint (see [list of regions and
endpoints](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region)).
This may be necessary for buckets in regions that only support AWS Signature
Version 4.

## Deploy

You should now be able to deploy your website to the AWS using the following command:
Expand Down
4 changes: 3 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-aws-s3 "0.3.7"]
[clj-aws-s3 "0.3.10" :exclusions [joda-time]]
[joda-time/joda-time "2.9.2"]
[me.kanej/s3-sync "0.4.0"]
[org.clojure/data.json "0.2.6"]
[org.clojure/java.data "0.1.1"]]
:eval-in-leiningen true
:min-lein-version "2.0.0"
Expand Down
5 changes: 4 additions & 1 deletion src/leiningen/s3_static_deploy.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
(:import com.amazonaws.auth.BasicAWSCredentials
com.amazonaws.services.s3.AmazonS3Client
com.amazonaws.ClientConfiguration
com.amazonaws.SDKGlobalConfiguration
com.amazonaws.services.s3.model.BucketWebsiteConfiguration))

(defn- s3-client*
Expand Down Expand Up @@ -55,9 +56,11 @@
(defn s3-static-deploy [project & args]
"Deploy a local directory as a static website in AWS S3."
(let [aws (:aws project)
credentials (select-keys aws [:access-key :secret-key])
credentials (select-keys aws [:access-key :secret-key :endpoint])
{bucket :bucket local-root :local-root} (:s3-static-deploy aws)]

(when (:endpoint credentials)
(System/setProperty SDKGlobalConfiguration/ENABLE_S3_SIGV4_SYSTEM_PROPERTY "true"))
(println (str "Deploying " local-root " to " bucket))
(when-not (bucket-exists-in-account? credentials bucket)
(s3/create-bucket credentials bucket))
Expand Down