Skip to content

Commit 6ca2bfe

Browse files
committed
2.0.0 support canned acls
1 parent 37a9895 commit 6ca2bfe

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ a boot task for spewing files into an S3 bucket.
44

55
[](dependency)
66
```clojure
7-
[tailrecursion/boot-bucket "1.1.0"] ;; latest release
7+
[tailrecursion/boot-bucket "2.0.0"] ;; latest release
88
```
99
[](/dependency)
1010

@@ -21,16 +21,16 @@ file basis to configure HTTP headers in S3 and cloundfront.
2121

2222
in a departure from previous releases, as of `2.0.0`, boot-bucket defaults to
2323
the `:private` canned ACL, which should be changed to `:public-read` when
24-
serving files from an S3 bucket. alternately, any of the following canned ACL
25-
keywords may be specified to the `access-control` parameter:
24+
serving files from an S3 bucket. alternatively, any of the following canned ACL
25+
keywords may be specified to the `canned-acl` parameter:
2626

2727
```
2828
:private (default)
29-
:log-delivery-write
30-
:bucket-owner-read
31-
:bucket-owner-full-control
32-
:authenticated-read
33-
:public-read
29+
:log-delivery-write
30+
:bucket-owner-read
31+
:bucket-owner-full-control
32+
:authenticated-read
33+
:public-read
3434
:public-read-write
3535
```
3636

@@ -92,9 +92,9 @@ with [boot-front][1] for deployments:
9292
(task-options!
9393
serve {:port 3001}
9494
sift {:include #{#"index.html.out/" #"<app-ns>/"} :invert true}
95-
spew {:access-control :public-read
96-
:access-key (System/getenv "<AWS_ACCESS_KEY_ENV_VAR>")
97-
:secret-key (System/getenv "<AWS_SECRET_KEY_ENV_VAR>")}
95+
spew {:canned-acl :public-read
96+
:access-key (System/getenv "<AWS_ACCESS_KEY_ENV_VAR>")
97+
:secret-key (System/getenv "<AWS_SECRET_KEY_ENV_VAR>")}
9898
burst {:access-key (System/getenv "<AWS_ACCESS_KEY_ENV_VAR>")
9999
:secret-key (System/getenv "<AWS_SECRET_KEY_ENV_VAR>")})
100100
```
@@ -107,10 +107,10 @@ an `index.html.js` artifact that was compressed upstream by another task like
107107

108108
```clojure
109109
(spew
110-
:access-key "<aws-access-key>"
111-
:secret-key "<aws-secret-key>"
112-
:access-control :public-read
113-
:metadata {"index.html.js" {:content-encoding "gzip"}})
110+
:canned-acl :public-read
111+
:access-key "<aws-access-key>"
112+
:secret-key "<aws-secret-key>"
113+
:metadata {"index.html.js" {:content-encoding "gzip"}})
114114
```
115115

116116
note that it's often important to zip CLJS output as core/goog can weigh in at

build.boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(require
77
'[adzerk.bootlaces :refer :all])
88

9-
(def +version+ "1.1.0")
9+
(def +version+ "2.0.0")
1010

1111
(bootlaces! +version+)
1212

src/tailrecursion/boot_bucket.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
(update :dependencies into deps))))
2424

2525
(boot/deftask spew
26-
[b bucket NAME str "AWS Bucket Identifier"
27-
a access-key ACCESS_KEY str "AWS Access Key"
28-
s secret-key SECRET_KEY str "AWS Secret Key"
29-
m metadata META edn "Map of the form {\"index.html\" {:content-encoding \"gzip\"}}"]
26+
[b bucket NAME str "AWS Bucket Identifier"
27+
a access-key ACCESS_KEY str "AWS Access Key"
28+
s secret-key SECRET_KEY str "AWS Secret Key"
29+
c canned-acl ACL kw "A keyword indicating which predefined ACL should be used."
30+
m metadata META edn "Map of the form {\"index.html\" {:content-encoding \"gzip\"}}"]
3031
(let [pod (pod/make-pod (pod-env deps))
3132
out (boot/tmp-dir!)]
3233
(boot/with-pre-wrap fileset

src/tailrecursion/boot_bucket/client.clj

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
[com.amazonaws.services.s3.model CannedAccessControlList]
1212
[com.amazonaws.services.s3.model ObjectMetadata]))
1313

14+
(def canned-acls
15+
{:private CannedAccessControlList/Private
16+
:log-delivery-write CannedAccessControlList/LogDeliveryWrite
17+
:bucket-owner-read CannedAccessControlList/BucketOwnerRead
18+
:bucket-owner-full-control CannedAccessControlList/BucketOwnerFullControl
19+
:authenticated-read CannedAccessControlList/AuthenticatedRead
20+
:public-read CannedAccessControlList/PublicRead
21+
:public-read-write CannedAccessControlList/PublicReadWrite})
22+
1423
(defn client [acc-key sec-key]
1524
(-> (BasicAWSCredentials. acc-key sec-key)
1625
(AmazonS3Client.)
@@ -33,13 +42,13 @@
3342
"content-type" (.setContentType o v)
3443
(.addUserMetadata o k v)) o)
3544

36-
(defn request [bucket base-dir path metadata]
45+
(defn request [bucket base-dir path acl metadata]
3746
(doto (PutObjectRequest. bucket path (io/file base-dir path))
38-
(.withCannedAcl CannedAccessControlList/PublicRead)
47+
(.withCannedAcl (canned-acls acl CannedAccessControlList/Private))
3948
(.withMetadata (reduce-kv meta-set! (ObjectMetadata.) (get metadata path)))))
4049

41-
(defn put-file! [{:keys [access-key secret-key bucket metadata]} base-dir path]
50+
(defn put-file! [{:keys [access-key secret-key bucket canned-acl metadata]} base-dir path]
4251
(let [client @(client access-key secret-key)
43-
req (request bucket base-dir path metadata)]
52+
req (request bucket base-dir path canned-acl metadata)]
4453
(.putObject client req)
4554
path))

0 commit comments

Comments
 (0)