Welcome!

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.
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
hostname
instance-id
instance-type
local-hostname
local-ipv4
placement/
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups


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"/>

</fileset>

</path>

<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="http://169.254.169.254/1.0/user-data" 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>

</target>

</project>


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
Pre-requisite
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.

    accessKey=aaaaa2323123bcv
    secretKey=sce3434343#$$$$vvxcvx/sdfsdfs
    bucketName=mybucket
    buildFile=mybuild.xml


    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.
    http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1450
    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
    "MobiDev is a Ukraine-based software development company. We do mobile development, and we're specialists in that. But we do full stack software development for entrepreneurs, for emerging companies, and for enterprise ventures," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
    What's the role of an IT self-service portal when you get to continuous delivery and Infrastructure as Code? This general session showed how to create the continuous delivery culture and eight accelerators for leading the change. Don Demcsak is a DevOps and Cloud Native Modernization Principal for Dell EMC based out of New Jersey. He is a former, long time, Microsoft Most Valuable Professional, specializing in building and architecting Application Delivery Pipelines for hybrid legacy, and cloud ...
    With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
    SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
    21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
    SYS-CON Events announced today that TechTarget has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TechTarget storage websites are the best online information resource for news, tips and expert advice for the storage, backup and disaster recovery markets.
    DevOps at Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to w...
    You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
    "Tintri focuses on the Ops side of the DevOps, which basically is pushing more and more of the accessibility of the infrastructure to the developers and trying to get behind the scenes," explained Dhiraj Sehgal of Tintri in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
    "We focus on composable infrastructure. Composable infrastructure has been named by companies like Gartner as the evolution of the IT infrastructure where everything is now driven by software," explained Bruno Andrade, CEO and Founder of HTBase, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
    SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
    SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
    Hardware virtualization and cloud computing allowed us to increase resource utilization and increase our flexibility to respond to business demand. Docker Containers are the next quantum leap - Are they?! Databases always represented an additional set of challenges unique to running workloads requiring a maximum of I/O, network, CPU resources combined with data locality.
    The current age of digital transformation means that IT organizations must adapt their toolset to cover all digital experiences, beyond just the end users’. Today’s businesses can no longer focus solely on the digital interactions they manage with employees or customers; they must now contend with non-traditional factors. Whether it's the power of brand to make or break a company, the need to monitor across all locations 24/7, or the ability to proactively resolve issues, companies must adapt to...
    Cloud Expo, Inc. has announced today that Andi Mann and Aruna Ravichandran have been named Co-Chairs of @DevOpsSummit at Cloud Expo Silicon Valley which will take place Oct. 31-Nov. 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. "DevOps is at the intersection of technology and business-optimizing tools, organizations and processes to bring measurable improvements in productivity and profitability," said Aruna Ravichandran, vice president, DevOps product and solutions marketing...