Deploying a Scalatra App to Elastic Beanstalk via Codeship

I’ve recently started using Codeship – a cloud based Continuous Integration and Deployment environment – for a “Just for fun” project I needed to deploy to AWS, specifically to Elastic Beanstalk. At the time of this writing, there were no AWS plugins available on Codeship to make this deployment possible but, thanks to one of their Engineers (thanks you Florian), I was able to make it happen using the “Custom Script” option on Codeship, and the “ebs_deploy” tool by Brian Dilley.

As per the docs of Ebs Deploy, I added a “ebs.config” file in my repository that contains details about my AWS settings, my Elastic Beanstalk app settings and my environments. It also contains a section defining the type of file I want uploaded as well as the command the would build that file.

aws:
access_key: 'myKey'
secret_key: 'mySecretKey+TjnS'
region: 'us-east-1'
bucket: 'myBucket'
bucket_path: 'myPath'
app:
versions_to_keep: 10
app_name: 'myAppName'
description: 'My App Description'
all_environments:
solution_stack_name: '64bit Amazon Linux running Tomcat 7'
option_settings:
'aws:autoscaling:asg':
MinSize: 1
MaxSize: 10
'aws:elasticbeanstalk:application':
Application Healthcheck URL: '/'
# instructions on how to build the application archive
archive:
generate:
cmd: sbt package
output_file: .*target/.*\.war
environments:
# the Testing version of the app
'muzzy-app-dev':
cname_prefix: 'muzzy-app-dev'
# the production version of the app
'muzzy-app-prod':
cname_prefix: 'muzzy-app-prod'

view raw
ebs.config
hosted with ❤ by GitHub

With that added, I changed my deployment setting on my project in Codeship to use the “Custom Script” option, and entered the following commands

pip install ebs-deploy
ebs-deploy init
ebs-deploy deploy –environment muzzy-app-dev

view raw
codeship
hosted with ❤ by GitHub

The first command ensures that Ebs Deploy is present on my environment. The second initialize my environments based on the ebs.config, which can be useful should I change/add new environments to that file. Finally, the third command does the actual deployment.

Et voila! I hope this helps!

Deploying a Scalatra App to Elastic Beanstalk via Codeship

3 thoughts on “Deploying a Scalatra App to Elastic Beanstalk via Codeship

    1. My main reason for using ebs-deploy over aws-cli was its simplicity. ebs-deploy abstracts away the various commands I would have needed to replicate with aws-cli. By me providing just a config file, it knows to create or update my elastic beanstalk application and its environments, how to build my application and how to upload its new version to elastic beanstalk. As such the only thing I need to maintain is the config, not the script I would have written to work with aws-cli. It also has a single command to do zero down time deployment, which also saves me having to write a script with aws-cli to do the same thing.

      I hope this helps!
      Boguste

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s