Tuesday Jun 16, 2009

How to Setup iPhone AWS manager on OpenSolaris EC2 Instance


Project Link: http://code.google.com/p/iphone-aws-manager/

I was looking for the free iPhone application to manage my ec2 account and came across this article: "Mobile Monitoring and Administration of Amazon Web Services: Developing an iPhone-Optimized Web Application".

This article not only describes in details each steps on how to begin with developing iPhone application to manage AWS but also provides source code that you easily download from Google Code Repository and setup in-house.

In this blog entry I will walk you through steps on setting up this application on our popular OpenSolaris AMP Stack AMI.

Following Steps are also valid for the setup of "iPhone AWS Manager" on local machine with OpenSolaris and AMP Stack.

Lets begin with launching new OpenSolaris AMP Stack AMI Instance.
ec2-run-instances ami-c7cf28ae -k my-keypair

Get the public DNS address of an Instance and login into with your keypair
ec2-describe-instances i-xxxxxxxx
ssh -i <path_to_your_keypair> root@ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com

Install SVN Package from the Repository
pkg refresh
pkg install SUNWsvn

Checkout iPhone AWS Manager code form the Google Code Repository
cd /var/apache2/2.2/htdocs/

svn co http://iphone-aws-manager.googlecode.com/svn/trunk/ aws-iphone
A aws-iphone/amis.php
A aws-iphone/class.s3.php
A aws-iphone/reboot.php
A aws-iphone/deleteobj.php
A aws-iphone/contents.php
A aws-iphone/getbuckets.php
A aws-iphone/delete.php
A aws-iphone/create.php
A aws-iphone/run.php
A aws-iphone/index.php
A aws-iphone/about.php
A aws-iphone/size.php
A aws-iphone/class.ec2.php
A aws-iphone/lib
A aws-iphone/lib/iui
A aws-iphone/lib/iui/backButton.png
A aws-iphone/lib/iui/grayButton.png
A aws-iphone/lib/iui/loading.gif
A aws-iphone/lib/iui/pinstripes.png
A aws-iphone/lib/iui/toolbar.png
A aws-iphone/lib/iui/iuix.js
A aws-iphone/lib/iui/toolButton.png
A aws-iphone/lib/iui/whiteButton.png
A aws-iphone/lib/iui/iui.js
A aws-iphone/lib/iui/toggleOn.png
A aws-iphone/lib/iui/thumb.png
A aws-iphone/lib/iui/toggle.png
A aws-iphone/lib/iui/iuix.css
A aws-iphone/lib/iui/blueButton.png
A aws-iphone/lib/iui/cancel.png
A aws-iphone/lib/iui/selection.png
A aws-iphone/lib/iui/listArrow.png
A aws-iphone/lib/iui/listGroup.png
A aws-iphone/lib/iui/iui.css
A aws-iphone/lib/iui/listArrowSel.png
A aws-iphone/iPhone AWS Source Code.zip
A aws-iphone/instances.php
A aws-iphone/terminate.php
Checked out revision 3.


Set the Document Root in the httpd.conf file
vi /etc/apache2/2.2/httpd.conf

Set the DocumentRoot as given below
DocumentRoot "/var/apache2/2.2/htdocs/aws-iphone"

edit /etc/php/5.2/php.ini and set following variables to On
register_globals = On
register_long_arrays = On

Create "key.php" file at "/var/apache2/2.2/htdocs/aws-iphone/keys.php" with following code

<?php 
define('my_access_key','XXXXXXXXXXXXXXXXXXXX'); define('my_secret_key','XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
?>

Edit "/var/apache2/2.2/htdocs/aws-iphone/index.php" file and replace php code block at the top of the page with following code.
<?php
        // start the session
        session_start();

        // include the EC2 and S3 libraries
        require_once("class.ec2.php");
        require_once("class.s3.php");
        include_once("keys.php");
        // create session variables for AWS keys
        session_register("AMAZON_KEY");
        session_register("AMAZON_PRIVATE_KEY");

        $HTTP_SESSION_VARS["AMAZON_KEY"]=my_access_key;
        $HTTP_SESSION_VARS["AMAZON_PRIVATE_KEY"]=my_secret_key;
?>

change your keypair in "/var/apache2/2.2/htdocs/aws-iphone/class.ec2.php" file
look for the function definition and replace your keyName

function runInstances($imageId, $min = 1, $max = 1, $keyName = "divyen-personal-aws-key")


Restart the Apache Server
svcadm disable svc:/network/http:apache22
svcadm enable svc:/network/http:apache22

Open Safari Browser in your iPhone and type in EC2 Instance DNS Address





Create a Shortcut icon so that you don't need to type in URL every time





Snapshots of the basic operations supported on this application are described as given below

Describe AMIs - Both Public and Private





Create Instance, Reboot Instance, Terminate Instance





Create Bucket, Delete Bucket





About

Divyen Patel

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today