Skip to content

Instantly share code, notes, and snippets.

@jamesdavidson
Created March 25, 2015 04:56
Show Gist options
  • Select an option

  • Save jamesdavidson/65b16dc4c5f964cb3ead to your computer and use it in GitHub Desktop.

Select an option

Save jamesdavidson/65b16dc4c5f964cb3ead to your computer and use it in GitHub Desktop.
Make a HTML list of names from S3 bucket meta-data.
; Retrieve a list of buckets.
; Retrieve the access-control-list.
; For each, print the owner's display-name.
(ns com.example
(:use amazonica.core
amazonica.aws.s3
clojure.pprint))
(defn retrieve-name [bucket]
(:display-name
(:owner
(get-bucket-acl
(:name bucket)))))
(defn bullet-list [title items]
(str "<p>" title "</p>"
"<ul>" items "</ul>"))
(defn bullet-point [item]
(str "<li>" item "</li>"))
(defn write-index-html [output]
(spit "index.html"
(str
"<html>"
"<head>"
"<title>hello</title>"
"</head>"
"<body>"
"<div>"
output
"</div>"
"</body>"
"</html>")))
(write-index-html
(bullet-list
"bucket owners"
(reduce str ""
(map (comp bullet-point retrieve-name)
(list-buckets)))))
@davidporter-id-au
Copy link

Nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment