Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi i have started with aws and found out that we can get a list of running servers with the aws php sdk. Is there any other way to get the list of all ec2 instances? after getting the list i want to sync the data from one main instances to all the instances. Something like a button click can also do the operation. Are rsync, incron the only options, or it can be done by aws php sdk also. Please provide some tutorial links.

share|improve this question
you might want to submit another question with more details of your requirements regarding the data sync part of your question, as I feel thats its probably quite a bit different to the AWS part... – Tom H Mar 20 '12 at 14:41
the steps suggested worked like a charm. Will be posting a new question for the rest part. Thanks. – user113981 Mar 21 '12 at 18:32
up vote 3 down vote accepted

I think you would use the AWS php sdk;

Run through the getting started guide to setup your keys;

And then use the describe_instances function to collect an array of instances;

It looks like you could either construct and filter to return only running instances, or then loop over the returned like to to get more detailed information using the describe_instance_status function;

Something tlike the following will work...

require_once "/home/XXX/src/php-aws-sdk-1.5.3/sdk.class.php";
    'testing' => array(
        'key' => 'XXX',
        'secret' => '+YYY+',
        'default_cache_config' => '',
        'certificate_authority' => false
    // Specify a default credential set to use if there are more than one.
    '@default' => 'testing'
$ec2 = new AmazonEC2();
$response = $ec2->describe_instances(array( "Filter" => array(
  array("Name"=>"instance-state-code", "Value" => "16"))));
foreach($response as $res){
 var_dump( $res );

instance state code 16 is for "running"

share|improve this answer
hi @tom,can u help me?I have added the code in above manner.But I have been getting error 'include(CFCredentials.php): failed to open stream: No such file or directory '.Please help me ASAP. – Sujathan R Mar 29 '13 at 13:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.