Home > amazon, beanstalk, ec2 > Script to start an Amazon Elastic Beanstalk application from command line

Script to start an Amazon Elastic Beanstalk application from command line

February 3rd, 2011

After playing around with Amazon Elastic Beanstalk, I started to explore the command line tools.

Starting an Amazon Elastic Beanstalk application from the AWS console is easy and reasonably fast. The main problem is that you can’t currently provide additional settings such as the instance type (e.g. m1.small or t1.micro), a SSH key or application parameters.

After starting the application environment, it must be stopped again, before the configuration can be changed. This costs an instance hour but, more importantly, this procedure takes quite a while, as AWS must reconfigure the load balancer, auto-scaling group, start your instance(s), etc.

I created a script, which can be used to start an application environment from the command line. The most important parameters can be set as command line parameters:

All you need is to install the Elastic Beanstalk command line tools and my script.

Example

Starting an application myapp with environment myenv on a m1.small instance with SSH key mysshkey is as simple as:

eb-create-app.sh -a myapp -k mysshkey -e myenv -t m1.small -f 'mybucket/myapp.war'

Some notes:

  • the application WAR file must already be uploaded to S3. The format of the file name (parameter -f) is bucketname/key. If the file name is not specified, Beanstalk will deploy the sample application
  • the environment can only be created, if the CNAME (which is identical to the environment name, if not specified with -c) is not already used. The CNAME is used as sub-domain under elasticbeanstalk.com. When creating an environment with name (and CNAME) myenv, the full DNS name would be myenv.elasticbeanstalk.com
  • starting an environment will fail, if the SSH key name does not exist. You can look up the name of your SSH key in the EC2 console

Elastic Beanstalk Parameters

Elastic Beanstalk provides many parameters, which can be set. A full list can be obtained using elastic-beanstalk-describe-configuration-settings, also from the command line tools (NOTE: fix required!).

I created a list of all Elastic Beanstalk configuration options using another script (requires ruby gem jazor):

The long version in JSON format is available here.

Final words

Starting an application environment is easy and the command line tools help a lot. There are still some bugs, but I’m sure, the Beanstalk team will address them soon. The forum is a great resource.

My next post will be about creating a customized Beanstalk AMI. Stay tuned!

Categories: amazon, beanstalk, ec2 Tags:
  1. No comments yet.
Comments are closed.
Fork me on GitHub