Deploy to AppFog PaaS using Cloud Foundry Integration plugin of Eclipse / STS

AppFog Cloud Platform is built by using the Cloud Foundry OSS bits alongside its own set of custom extensions and enhancements. AppFog provides good command line tool to deploy application but we can configure Cloud Foundry Integration plugin of Eclipse / Spring Tool Suite (STS) to deploy web application directly from IDE to the AppFog.

Technologies used in this article

  1. Spring Tool Suite
  2. Cloud Foundry Integration Extension for STS
  3. AppFog PaaS

1. Create a Dynamic Web Project

Create a dynamic web project (say 'AFHello') with a jsp page (say 'afHello.jsp'). We'll deploy this web application to AppFog Cloud Platform.
File : afHello.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>App Fog Hello</title>
</head>
<body>
Successfully deployed in App Fog cloud using Cloud Foundry Integration plugin of Eclipse / STS
</body>
</html>

2. Install Cloud Foundry Integration Extension

Install Cloud Foundry Integration Extension in Eclipse or Spring Tool Suite (STS) IDE

3. Define a new server

Click File --> New --> Other --> Server --> VMware --> Cloud Foundry

4. Add AppFog cloud url

Click 'Manage Cloud' --> 'Add'. Enter the AppFog cloud url 'https://api.appfog.com' and click the 'Finish' button.

5. Configure AppFog Account

Enter AppFog account's email, password and select App Fog Cloud as url. Click the 'Validate Account' button to check whether all the configurations are correct ot not. Click 'Finish' button.

6. Deploy Application

Drag your application and drop it to the 'App Fog Cloud' server. Provide 'Application Details' and click 'Next' button.

In 'Launch Deployment' window provide deployed url (for example 'afhello.aws.af.cm').


Note:
Deployed url needs to be unique and it is comprised of two parts - subdomain (eg. afhello) and infrastructure (Amazon Web services - aws.af.cm) where we want to deploy our application. AppFog provides different OpenStack-based IaaS like Rackspace or HP to AWS. As of now, following infrastructures are provided by AppFog PaaS

  1. AWS Asia Southeast (.ap01.aws.af.cm)
  2. AWS Europe West (.eu01.aws.af.cm)
  3. AWS US East (.aws.af.cm)
  4. HP Openstack AZ 2 (.hp.af.cm)
  5. Rackspace DFW (.rs.af.cm)

If the url is already used by any other AppFog user then you can change the same using the 'Edit' button of 'Mapped Url'

7. Browser output

Open the mapped url ('afhello.aws.af.cm') in the browser.

Download SrcCodes

All code samples shown in this post are available in the following link AFHello.zip

References