We provide a variety of services including:

·          Training classes for Spring, Hibernate and Acegi Security

·          Jumpstarts to get your project off to the right start

·          Reviews to improve your architecture, code and development process

For more information visit our website: http://www.chrisrichardson.net

Home > Knowledge > EC2

Using the Cloud Tools Maven Plugin

Cloud Tools provides a Maven plugin for deploying a Maven web application project to EC2 and running load tests. The plugin uses EC2Deploy and so you need to follow some of its setup instructions. Most notably, you must first create an aws.properties file and install the Jets3t synchronize.jar in your maven repository.

Goals

There are the following goals:

Goal Description Required properties
cloudtools:deploy Deploy the application on EC2 (note mvn package must have been run)  
cloudtools:redeploy Redeploy the application (note mvn package must have been run)  
cloudtools:jmeter Run a jmeter load test cloudtools.jmxTestFile

cloudtools.threadCount

cloudtools:stop Terminate the instances  
cloudtools:dbsave save a database snapshot in S3 cloudtools.s3.path
cloudtools:dbrestore restore the database from S3 cloudtools.s3.path
cloudtools:clone creates a copy of the cluster cloudtools.new.cluster.name
cloudtools:describe describes the cluster  
cloudtools:list lists the available clusters  
cloudtools:stop shutdown the cluster  

All goals require the cloudtools.aws.properties property to be set. In addition, you can specify the cluster name using the cloudtools.cluster.name. It defaults to maven-cluster

Configuration

Here is an example configuration of the plugin in your web application's pom.xml

<repositories>
   <repository>
      <id>pia-repository</id>
      <url>http://www.pojosinaction.com/repository</url>
   </repository>
</repositories>
<pluginRepositories>
   <pluginRepository>
      <id>pia-repository</id>
      <url>http://www.pojosinaction.com/repository</url>
      <snapshots>
      <enabled>true</enabled>
      </snapshots>
   </pluginRepository>
</pluginRepositories>
<build>
  <plugins>
     <plugin>
                <groupId>net.chrisrichardson</groupId>
                <artifactId>cloudtools-maven-plugin</artifactId>
                <configuration>
                    <awsPropertiesFile>${cloudtools.plugin.awsPropertiesFile}</awsPropertiesFile>
                    <schemaName>ptrack</schemaName>
                    <schemaUsers>
                        <param>
                            ptrack:ptrack
                        </param>
                    </schemaUsers>
                    <sqlScripts>
                        <param>script1.sql</param>
                        <param>script2.sql</param>
                    </sqlScripts>
                    <catalinaOptsBuilder>
                        {builder, databasePrivateDnsName ->
                            builder.arg("-server")
                            builder.arg("-Xmx1000m")
                            builder.prop("com.sun.management.jmxremote")
                            builder.prop("com.sun.management.jmxremote.port", 8091)
                            builder.prop("com.sun.management.jmxremote.authenticate", false)
                            builder.prop("com.sun.management.jmxremote.ssl", false)
                            builder.prop("ptrack.application.environment", "ec2") 
                            builder.prop("jdbc.db.server", databasePrivateDnsName)}
                    </catalinaOptsBuilder>
                </configuration>
            </plugin>
  </plugins>
</build>