views:

23

answers:

1

I am using Zend Framework's library to manage EC2 instances and AMI. However I can't list the AMI's I own and can't list existing EC2 instances.

$ec2Instance = new Zend_Service_Amazon_Ec2_Instance($awsAccessKey, $awsSecretKey);
$instances = $ec2Instance ->describe();

$ec2Instance ->describe() should list all instances but it is returning no instances even though I have three of them running at this time.

$ami = new Zend_Service_Amazon_Ec2_Image($awsAccessKey, $awsSecretKey);
$images = $ami->describe();

$ami->describe() returns all the public images but none of them are the ones I created even though I have two AMIs.

Does any one know what I am missing here?

+1  A: 

The problem was that you have to explicitly set the region for your instances.

As of version 1.10.3 of Zend Framework the following will not work because it will set a different variable internally:

$ec2Instance = new Zend_Service_Amazon_Ec2_Instance($awsAccessKey, $awsSecretKey);
$ec2Instance->setRegion('us-west-1');

Moreover us-west-1 is considered as an invalid region using version 1.10.3 of Zend Framework.

Instead setting the region in the constructor will make it work:

$ec2Instance = new Zend_Service_Amazon_Ec2_Instance($awsAccessKey, $awsSecretKey, 'us-west-1');

Then I was able to use $ec2Instance ->describe() to list all my instances.

Marcel Tjandraatmadja