Home > Development > Deploy Grails Apps in 3 simple steps to Amazon Beanstalk

Deploy Grails Apps in 3 simple steps to Amazon Beanstalk

February 18, 2011 Leave a comment Go to comments

We can easy deploy the Grails WAR file to Amazon Beanstalk in 3 simple steps:

  • We have to create an Amazon Web Services Account (this part is not described is this post)
  • We have to make a MySQL database. We use Amazon RDS
  • We have to make the Amazon Elastic Beanstalk and deploy the WAR

Important note before you start!

We need security groups, to connect local client tools and Amazon Elastic Beanstalk to the MySQL Database Instance.  To succeed to make this connection it is important to install Amazon RDS and Amazon Elastic Beanstalk in the same region. At this moment you can choose only select one region for setting up Amazon Elastic Beanstalk (US  East) so your region for Amazon RDS must be ‘US East’.

Make MySQL Database Instance with Amazon RDS

1) Sign in to the AWS Management Console and choose for the RDS tab

2) Press the Launch DB Instance Button

You see the first screen. In our case we fill in the following:

Allocated Storage: 5
DB Instance Identifier: db
Master User Name: root
Master User Password: mysql

The other fields will have the default value

3) In the second screen you can enter some additional configuration

Database name: database

The other fields will have the default value

4) In the other screen you can enter some management options like backup scedule etc.

5) After you review all the info and pressing the Launch button you get an available MySQL Database Instance!

Fill in the DB security group to authorize access from local client tools and elastic beanstalk

Enter in the default security group:

1) a CIDR/IP connection type with IP/32 of the machine with client tools. Fill in your IP, to haven direct access with your own client tools
2) a EC2 Security Group type with Security Group:elasticbeanstalk-default and enter your AWS Account ID

Make the elastic beanstalk and deploy the Grails WAR

1) We use the production evironment option in the datasource.groovy to put in the Amazon information. Use the endpoint of the Amazon RDS / MySQL Database Instance as the machinename and the Amazon Beanstalk environment in the jdbc connection.

production {
        dataSource {
            pooled = true
            driverClassName = "com.mysql.jdbc.Driver"
            dbCreate = "update" // one of 'create', 'create-drop','update'
            username = 'root'
            password = 'mysql'
            url = 'jdbc:mysql://'endpoint':3306/'environment''
            dialect = org.hibernate.dialect.MySQL5InnoDBDialect
            properties {
                validationQuery = "SELECT 1"
                testOnBorrow = true
                testOnReturn = true
                testWhileIdle = true
                timeBetweenEvictionRunsMillis = 1000 * 60 * 30
                numTestsPerEvictionRun = 3
                minEvictableIdleTimeMillis = 1000 * 60 * 30

2) Create the Grails WAR with the correct datasource.groovy file.

Enter an environment is our case : environment

Upload a Grails WAR file: appname.war

You can edit your environment. See the manual Elastic Beanstalk guide

After successfully upload en deploy of the Grails WAR file you see a little green square!

At this point you have successfully upload and deploy your Grails App to the Amazon Cloud!!!

Look at http://environment.elasticbeanstalk.com/ and enjoy!!!

  1. Eric Turner
    February 25, 2011 at 01:14

    Note that you’ll be charged quite a bit for your RDS instance! I followed this and deployed a small Grails app less than 10 days ago, with very low bandwidth and actual storage used, and my cost is currently up over $21 USD. I’ve undeployed my app until I can find a cheaper way to make this work without using RDS.

  2. malderhout
    February 25, 2011 at 10:03

    Hi Eric,
    Thx for your comment. I noticed that RDS take a big part of the costs. In our project we use MySQL as database, so RDS is the best fit for now. We have a lot of customers and we can configure Grails as a multi-tenant environment (one instance and one scheme). This is the cheapest way in our case, because we can share those costs with al lot of customers.

    • August 27, 2014 at 12:11

      Hi, we are planning to deploy our app as a multitenant environment using beanstalk, and we need no sharing (one instance per tenant), please guide me how you have deployed and how you used RDS for cost effective? appreciate your help..
      thnx – Venu

  3. Lim Chee Kin
    March 20, 2011 at 07:14

    Hi Eric,

    Have you found any way to use Amazon Beanstalk without RDS?

    Chee Kin

  4. Keith Thomas
    October 17, 2011 at 22:12

    Hi, I’m afraid I’m still unclear about how to setup the database URL. How do I map ‘endpoint’ and ‘environment’ to my RDS mysql instance?

  5. April 10, 2013 at 06:04

    Greetings from Ohio! I’m bored to death at work so I decided to browse your website on my iphone during lunch break. I love the knowledge you present here and can’t wait
    to take a look when I get home. I’m amazed at how fast your blog loaded on my mobile .. I’m not even using
    WIFI, just 3G .. Anyways, very good blog!

  6. May 11, 2013 at 05:49

    Hello There. I found your blog using msn. This is an extremely well written article.
    I will be sure to bookmark it and come back to read
    more of your useful info. Thanks for the post.
    I will certainly return.

  7. July 27, 2013 at 20:50

    MB6-502 exam is about configuring multiple business related items ,working with
    route related switch nodes, creating and setting up product builder
    form ,product model and price combination. Nowadays all are aware about the
    web forms visible in various sites. There is not any real proof that training can benefit from protein

  8. August 5, 2013 at 16:09

    However, there are several online interfaces available where one needs to click
    on different types of options to send HTML code in email or to generate HTML code.

    For professional web site builders extra complex laptop software program for net design is needed.
    Net’s builder has been out for a little more than a year, yet it already helped more than 5,000 webmasters to create their online forms.

  9. Linda
    December 24, 2014 at 22:04

    Routes at minibus stations are usually in Chinese or not clearly stated.
    Application virtualization saves on hardware costs as well as licensing
    costs required for OS and software. Ten One Design Pogo Sketch Stylus Green for Apple i – Phone 4, i – Pod Touch, i – Pad and Blackberry 9300 9530 Strom 9550 Strom2 9800 Bold
    Motorola Droid x.

  1. October 10, 2011 at 12:04

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: