Skip to content

Instantly share code, notes, and snippets.

@codification
Last active July 12, 2017 09:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codification/442f09cb52c2efe62d7fcc91907c75ec to your computer and use it in GitHub Desktop.
Save codification/442f09cb52c2efe62d7fcc91907c75ec to your computer and use it in GitHub Desktop.
docker-for-aws in clojure using amazonica
(set-env!
:source-paths #{"src/clj"}
:resource-paths #{"resources"}
:dependencies '[[org.clojure/clojure "1.9.0-alpha14"]
[amazonica "0.3.78"]])
(ns docker-for-aws
(:require [amazonica.aws.cloudformation :as cf]))
(def key-pair-name "testing-docker-for-aws") ;; obviously use a key you have here
(def docker-for-aws-beta-template-url
"https://docker-for-aws.s3.amazonaws.com/aws/beta/aws-v1.13.0-rc2-beta12.json")
(defn create-docker-stack []
(cf/create-stack {:endpoint "eu-central-1"}
:stack-name "test-stack-1"
:template-url docker-for-aws-beta-template-url
:capabilities ["CAPABILITY_IAM"]
:parameters [{:parameter-key "KeyName"
:parameter-value key-pair-name}
{:parameter-key "InstanceType"
:parameter-value "t2.micro"}
{:parameter-key "ManagerInstanceType"
:parameter-value "t2.micro"}
{:parameter-key "ClusterSize"
:parameter-value "1"}]))
(ns finding-the-default-dns
(:require [amazonica.aws.elasticloadbalancing :as elb]))
;; Just a simple hack to get the public dns of the default configured ELB
(defn find-default-dns-target []
(->> (elb/describe-load-balancers {:endpoint "eu-central-1"})
:load-balancer-descriptions
(filter #(-> %
:load-balancer-name
(clojure.string/starts-with? "test-stack-1")))
first
:dnsname))
@codification
Copy link
Author

codification commented Dec 6, 2016

Oh, of course you need an AWS account, configured aws keys (~/.aws/credentials, environment variables or machine roles etc) and a clojure project with amazonica.

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