Zero to running in five minutes with lein.
The first thing we need is leiningen,
a build tool for clojure. You can downlaod this with your web browser, curl
or
wget
or your favourite download tool. Here we show using curl
.
bash$ curl -O http://github.com/technomancy/leiningen/raw/stable/bin/lein
bash$ chmod +x lein
Now we can create a new clojure project using lein. To do this we install the pallet project template, then use it to creat a project named 'quickstart'.
bash$ lein plugin install lein-newnew 0.2.4
bash$ lein plugin install org.cloudhoist/lein-pallet-new 0.1.1-SNAPSHOT
bash$ lein new pallet quickstart
Created new project in: quickstart
bash$ cd quickstart
Now you can configure your credentials.
bash$ lein plugin install org.cloudhoist/pallet-lein 0.4.2-SNAPSHOT
bash$ lein pallet add-service aws aws-ec2 your-aws-key your-aws-secret-key
Note that this creates a ~/.pallet/services/aws.clj
file with your credentials
in it.
The second argument above is the name of the jclouds provider, which is cloud specific. To find the value for other clouds, you can list the supported providers with:
bash$ lein pallet providers
Start a repl with lein repl
and load pallet with require
at the repl
user=>
prompt.
(require 'pallet.core 'pallet.compute 'pallet.configure)
You can now start your first compute node:
(pallet.core/converge
(pallet.core/group-spec "mygroup"
:count 1
:node-spec (pallet.core/node-spec :image {:os-family :ubuntu}))
:compute (pallet.configure/compute-service :aws))
To shut the node down again, change the :count
value to zero
:
(pallet.core/converge
(pallet.core/group-spec "mygroup"
:count 0)
:compute (pallet.configure/compute-service :aws))
Congratulations!