Skip to content

ck/lein-beanstalk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lein-beanstalk

Leiningen plugin for Amazon's Elastic Beanstalk

Prerequisites

You will need an Amazon Web Services account, and know your account key and secret key.

You will also need to be signed up for Elastic Beanstalk.

Basic Configuration

To use lein-beanstalk, you'll need to add a few additional values to your project.clj file.

First, add lein-beanstalk as a development dependency:

:dev-dependencies [[lein-beanstalk "0.2.0"]]

Then add an :aws key with your AWS keys and Elastic beanstalk environments:

:aws {:access-key "XXXXXXXXXXXXXXXXXX"
      :secret-key "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"}

Deploy

You should now be able to deploy your application to the Amazon cloud using the following command:

$ lein beanstalk deploy development

Info

To get information about the application itself run

$ lein beanstalk info
Application Name : myapp
Description      : My Awesome Compojure App
Last 5 Versions  : 0.1.0-20110209030504
                   0.1.0-20110209030031
                   0.1.0-20110209025533
                   0.1.0-20110209021110
                   0.1.0-20110209015216
Created On       : Wed Feb 09 03:00:45 EST 2011
Updated On       : Wed Feb 09 03:00:45 EST 2011
Deployed Envs    : development (Ready)
                   staging (Ready)
                   production (Terminated)

and information about a particular environment execute

$ lein beanstalk info development
Environment Id   : e-lm32mpkr6t
Application Name : myapp
Environment Name : development
Description      : Default environment for the myapp application.
URL              : development-feihvibqb.elasticbeanstalk.com
LoadBalancer URL : awseb-myapp-46156215.us-east-1.elb.amazonaws.com
Status           : Ready
Health           : Green
Current Version  : 0.1.0-20110209030504
Solution Stack   : 32bit Amazon Linux running Tomcat 6
Created On       : Tue Feb 08 08:01:44 EST 2011
Updated On       : Tue Feb 08 08:05:01 EST 2011

Shutdown

To shutdown an existing environment use the following command

$ lein beanstalk terminate development

This terminates the environment and all of its resources, i.e. the Auto Scaling group, LoadBalancer, etc.

Cleanup

To remove any unused versions from the S3 bucket run

$ lein beanstalk clean

Configuration

AWS Credentials

The Amazon Web Services account key and secret key are in the project.clj file itself

:aws {:access-key "XXXXXXXXXXXXXXXXXX"
      :secret-key "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"}

Environments

Elastic Beanstalk environments can be define multipe ways in the project.clj file.

If no environments are specified, lein-beanstalk will create three default environments

  • development (with CNAME prefix myapp-development)
  • staging (with CNAME prefix myapp-staging)
  • production (with CNAME prefix myapp)

To override the default behavior, either have :environments point to vector of envionment symbols

:aws {:beanstalk {:environments [dev demo prod]
                  ...}
      ...}

or to a vector of maps

:aws {:beanstalk {:environments [{:name "dev"}
                                 {:name "demo"}
                                 {:name "prod"}]
                  ...}
      ...}

In either of the two case the following two environents will be created

  • dev (with CNAME prefix myapp-dev)
  • demo (with CNAME prefix myapp-demo)
  • prod (with CNAME prefix myapp-prod)

The second option allows to specify the CNAME prefix for that environment

:aws {:beanstalk {:environments [{:name "dev"
                                  :canme-prefix "myapp-development"}
                                 {:name "staging"
                                  :cname-prefix "myapp-demo"}
                                 {:name "prod"
                                  :canme-prefix "myapp"}]
                  ...}
      ...}

By default the CNAME prefix is <project-name>-<environment>.

S3 Buckets

Amazon Elastic Beanstalk uses Amazon Simple Storage Service (S3) to store the versions of the application. By default lein-beanstalk uses lein-beanstalk.<project-name> as the S3 bucket name.

To use a custom bucket, specify it in the project.clj file:

:aws {:beanstalk {:s3-bucket "my-private-bucket"
                  ...}}

Trouble-Shooting

Q: Why does my deployed web application still shows up as 'red' in the Elastic Beanstalk console?

A: Elastic Beanstalk sends a HTTP HEAD request to '/' to check if the application is running. Simply add the necessary handling to the application. e.g. for Compojure add

(HEAD "/" [] "")

About

Leiningen plugin for Amazon's Elastic Beanstalk service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 100.0%