Last active
July 12, 2017 09:47
-
-
Save codification/442f09cb52c2efe62d7fcc91907c75ec to your computer and use it in GitHub Desktop.
docker-for-aws in clojure using amazonica
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(set-env! | |
:source-paths #{"src/clj"} | |
:resource-paths #{"resources"} | |
:dependencies '[[org.clojure/clojure "1.9.0-alpha14"] | |
[amazonica "0.3.78"]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"}])) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.