Blog Feed Post

Application Deployment on EC2 made easier using Smart EC2 Tool

Those who have worked on EC2 must be familiar with the deployment issues, due to the dynamic nature of the EC2 environment. Since we have been working with EC2 for a long time, we have come up with a tool to manage our application deployment using ANT(ANT is a build tool hosted in APACHE projects) and we are sure that the rest of the world can also use it.

This tool is generic enough to be used in a non EC2 environment, but in this article, we focus only on EC2.

About SmartEC2 Tool

This tool has bunch of ant tasks which can be used in the EC2 environment.

BaseTask - This is the base for all the other tasks. Has a method to save files to a given location.

S3Download - Helps to download objects from S3 buckets. This tool uses Jets3t for this task.

HttpDownload - Simple HTTP file download task. It does not support HTTPS and HTTP based authentication. Used only for public URL's.

MetadataDownload - This downloads all metadata related to the instance and stores it as a property file in the given location. EC2 Meta data is available as a tree structure. This task downloads all the metadata in one short and makes it available as a linear property file.

A typical EC2 Metadata request would provide the following list.

The translated Metadata file contains data in the following fashion.

ami-id = ami-sdfes213
ami-launch-index = 0
ami-manifest-path = ?
block-device-mapping/0 = ?
block-device-mapping/1 = ?
hostname = ec2-67-202-43-212.compute-1.amazonaws.com
instance-id = i-qwewq132
instance-type = ?
local-hostname = ec2-67-202-43-212.compute-1.local
local-ipv4 = ?
public-hostname = ?
public-ipv4 = ?
public-keys/0 = sdfdsfsd-sdfsdf34543-#
reservation-id = ?

ReplaceProperty - This task helps you to replace any properties in the corresponding target file. At this point it can replace any one of the properties at a time.

Smart EC2 tool contains all of the tasks listed above and a default build.xml file.

<?xml version="1.0" encoding="UTF-8"?>

<project name="Ec2Ant" basedir="." default="execBuild">

<property name="localFolder" value="${basedir}"/>

<property name="s3buildPath" value="${localFolder}/s3build"/>

<property environment="env"/>

<path id="csslab.lib">

<fileset dir="lib">

<include name="**/*.jar"/>



<typedef name="s3download" classname="com.csslab.s3ant.s3.S3Download" classpathref="csslab.lib"/>

<typedef name="HttpDownload" classname="com.csslab.s3ant.core.HttpDownload" classpathref="csslab.lib"/>

<typedef name="ec2metadata" classname="com.csslab.ec2.MetadataDownload" classpathref="csslab.lib"/>

<typedef name="replaceproperty" classname="com.csslab.ec2.ReplaceProperty" classpathref="csslab.lib"/>

<target name="execBuild">

<mkdir dir="${s3buildPath}"/>

<echo>Using build path ${s3buildPath}</echo>

<HttpDownload fileUrl="" localFolder="${s3buildPath}"/> <loadproperties srcFile="${s3buildPath}/user-data"/>

<s3download accessKey="${accessKey}" secretKey="${secretKey}" bucketName="${bucketName}" S3ObjectPath="${buildFile}" localFolder="${s3buildPath}" saveFileAs="build.xml"/><ant antfile="${s3buildPath}/build.xml" dir="${s3buildPath}" inheritrefs="true"/>

<delete dir="${s3buildPath}"/>

<echo>Build completed successfully.</echo>



First section contains declaration for some of the properties used by the targets.
Next you will find the definition for all the four ant tasks.
Then you will see a target that gets executed when the ANT starts.

Deploying Smart EC2 on your AMI
Please download the following pre-requisites.
  • JDK 1.5 or later from Sun
  • Ant 1.7 from Apache
  • Download Smart EC2 from here (http://smartec2.s3.amazonaws.com/SmartEC2.zip). Unzip the file and you will find a lib folder and a build.xml file.
  • Setup your path to point to the Java and ANT binaries.

    How does it work?
    EC2 has a provision to launch AMI's by providing user-defined data as an input file. The build process expects certain important parameters like Access Key, Secure Key, build file path and bucket name where the build file is available. The user defined data should be in the below given format. The key names listed below are mandatory. But you are free to add your own keys for further build process.

    accessKey={your access Key}
    secretKey={your secret key}
    bucketName={your bucket name}
    buildFile={your build file path}

    A typical user-defined data file looks like the below one.


    Download the sample user data file here and store it locally. But you need to replace properties with the appropriate values.
    You can use putty to login to the instance once it is launched and change your directory to where you have installed Smart EC2. For the first time users, you need to install the tool and bundle your AMI. If you are not familiar with building AMI’s , you can use our Jboss AMI which is available for public. Please find the URL below.
    Let’s assume you have installed Smart EC2 under /var/local. This is where the tool is installed on the above mentioned AMI.
    You will use the following command to go to the tools home.
    Cd /var/local/SmartEC2
    Execute the command ant.
    This will download the user defined data from the EC2 server and make it available as ANT properties. And then it will download the build file created by you for your project and executes it.

    How can you benefit out of this?
    As we know ant has a wide variety of tasks which can ease your deployment process such as executing shell scripts, deploying war, ear files on to the container etc. So sky is the limit.
    We have created couple of sample build files(Sample1 , Sample2) in our S3 bucket for your reference as well.
    Subscribe to this user group to get more updates.
    You can download the source and build on top of it.

    For your convenience we have created a step by step screen shots to showcase as how we deploy our applications using this solution.

    Read the original blog entry...

    More Stories By Ezhil Arasan Babaraj

    At present building a start-up called Qruize Technologies. Qruize is an Information & Communication Technology Start-up based out of Chennai, India. The company comprises of two strategic business units, Qruize Labs- boutique technology research & consulting services and Qruize Apps- social media products and services. We are currently establishing our own operations in the USA and entering into strategic partnerships in the EMEA region.
    Website : http://qruize.com, http://qruizemedia.com
    blog : http://qruizetech.wordpress.com
    Specialties Technology Strategy Consulting, Cloud Computing, Grid Computing, Enterprise Portal Architecture, Software Architecture, Application Framework Design and Development

    Latest Stories
    The past few years have brought a sea change in the way applications are architected, developed, and consumed—increasing both the complexity of testing and the business impact of software failures. How can software testing professionals keep pace with modern application delivery, given the trends that impact both architectures (cloud, microservices, and APIs) and processes (DevOps, agile, and continuous delivery)? This is where continuous testing comes in. D
    Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
    Mobile device usage has increased exponentially during the past several years, as consumers rely on handhelds for everything from news and weather to banking and purchases. What can we expect in the next few years? The way in which we interact with our devices will fundamentally change, as businesses leverage Artificial Intelligence. We already see this taking shape as businesses leverage AI for cost savings and customer responsiveness. This trend will continue, as AI is used for more sophistica...
    In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
    The “Digital Era” is forcing us to engage with new methods to build, operate and maintain applications. This transformation also implies an evolution to more and more intelligent applications to better engage with the customers, while creating significant market differentiators. In both cases, the cloud has become a key enabler to embrace this digital revolution. So, moving to the cloud is no longer the question; the new questions are HOW and WHEN. To make this equation even more complex, most ...
    In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
    Blockchain is a shared, secure record of exchange that establishes trust, accountability and transparency across business networks. Supported by the Linux Foundation's open source, open-standards based Hyperledger Project, Blockchain has the potential to improve regulatory compliance, reduce cost as well as advance trade. Are you curious about how Blockchain is built for business? In her session at 21st Cloud Expo, René Bostic, Technical VP of the IBM Cloud Unit in North America, discussed the b...
    SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone in...
    With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
    Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
    As you move to the cloud, your network should be efficient, secure, and easy to manage. An enterprise adopting a hybrid or public cloud needs systems and tools that provide: Agility: ability to deliver applications and services faster, even in complex hybrid environments Easier manageability: enable reliable connectivity with complete oversight as the data center network evolves Greater efficiency: eliminate wasted effort while reducing errors and optimize asset utilization Security: imple...
    The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
    No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
    Companies are harnessing data in ways we once associated with science fiction. Analysts have access to a plethora of visualization and reporting tools, but considering the vast amount of data businesses collect and limitations of CPUs, end users are forced to design their structures and systems with limitations. Until now. As the cloud toolkit to analyze data has evolved, GPUs have stepped in to massively parallel SQL, visualization and machine learning.
    Modern software design has fundamentally changed how we manage applications, causing many to turn to containers as the new virtual machine for resource management. As container adoption grows beyond stateless applications to stateful workloads, the need for persistent storage is foundational - something customers routinely cite as a top pain point. In his session at @DevOpsSummit at 21st Cloud Expo, Bill Borsari, Head of Systems Engineering at Datera, explored how organizations can reap the bene...