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.
This file contains 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
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' |
With that added, I changed my deployment setting on my project in Codeship to use the “Custom Script” option, and entered the following commands
This file contains 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
pip install ebs-deploy | |
ebs-deploy init | |
ebs-deploy deploy –environment muzzy-app-dev |
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!
Thanks for writing up the blogpost about how to deploy with us. Really appreciate it.
Was there any specific reason you used ebs-deploy and not the aws-cli (https://github.com/aws/aws-cli)
best,
Flo
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
Thanks, that makes a lot of sense. I’ll keep that in mind once we will integrate with Beanstalk at Codeship directly.