Resources



Sample Code and Libraries

Amazon EC2 Client in PHP

Click for a printer friendly version of this document Printer Friendly Save to del.icio.us
Average Review:

This Amazon EC2 client in PHP is a simple, light-weight client app for managing Amazon EC2 images, instances, and key-pairs.

Submitted By: Jinesh@AWS  
AWS Products Used: Amazon EC2
Language(s): PHP

ec2-manager.gif

What's New?

  • The following updates were made on 2006-12-15
    • PHP client now uses the 2006-10-01 version of the WSDL
    • PHP client sets the User-Agent HTTP header to ec2-php-2.0/1.2-7816

Prerequisites

  • You must have a valid Amazon Web Services developer account.
  • You must be signed up to use Amazon EC2.
  • Requires PHP5.1+ or higher (PHP 5.2 is recommended).
  • Requires the following modules:
    • DOM module
    • OpenSSL module

Running The Sample

  1. Download an expand the attached .zip file.
  2. Edit the ws-amazon-ec2.php file to specify the location of your X.509 certificate and private key (PEM format):
    define('PRIVATE_KEY', 'REPLACE WITH PATHNAME OF YOUR PRIVATE KEY (pk-XXXXX.pem)');
    define('CERT_FILE', 'REPLACE WITH PATHNAME OF YOUR CERTIFICATE (cert-XXXXX.pem)');
  3. View the phpclient.php file in your browser: http://localhost/phpclient.php
    User name: demo
    Password: myec2man
  4. You can now manage your Amazon EC2 instances.
See the Readme.htm file included in the attachment for more information about this sample.

Discussion
Click to start a discussion on this document Create a New Discussion
No discussion has been created for this document.

Reviews
Create Review Write a Review

Buggy, Oct 23, 2006 9:02 AM
Reviewer: pairwise
Without any instances created, I'm showing several errors. The client looks like it still needs some work.

It works well enough, Nov 18, 2006 4:05 AM
Reviewer: rcamazon2005
See this thread in the forums http://developer.amazonwebservices.com/connect/thread.jspa?messageID=45541뇥. A few additions like specifying what groups of ports should be opened up and it will be fairly complete as far as launching instances is concerned. An tracking how long an instance has been up would be fine. But that tracking time up will be difficult as Amazon instances will not respond on ports unless they are opened up. That may require having a way of checking via the instance id probably via the Amazon keys. As far as what it claims to do is concerned 4 stars is fine.

Error, Aug 10, 2007 3:54 PM
Reviewer: pagebuildr
After defining my AWS variables and opening phpclient.php, this is the error message I get: Parse error: parse error, expecting `'('' in /Library/WebServer/Documents/ec2/code/ws-amazon-ec2-client.php on line 26 This looks promising, and I'd love to put it to use. Can you take a look at the error? I'm running the OS X version of Apache and PHP. Thanks.

Good Start!!!, Oct 16, 2007 8:22 AM
Reviewer: Edward Goldberg
Works first time for me!!!! Bugs: If you refresh the screen at some points it launches a new EC2! The keys did not show first pass, I added one more key and now it works... How do you get report updates? Great work, good look, good start, MORE MORE MOre we want the next version... Edward M. Goldberg

A good start, Jun 15, 2008 3:19 PM
Reviewer: E. Anuff
Nice simple user interface that's a good starting point for building custom management consoles for EC2 instances. My main complaint is that it uses the AWS SOAP API rather than the Query API, which means that it requires the user to get their X.509 certificate into it, rather than just the Access Key/Secret Key that are easier for most users for find, copy, and paste. For a project I based on this, I replaced the included SOAP API with simpler class.ec2.php found at http://code.google.com/p/php-aws/ and further modified class.ec2.php to use HTTP_Request instead of curl.
Welcome, Guest Help
Login Login