Search code examples
amazon-web-servicesamazon-ec2aws-php-sdk

AWS SDK for PHP how to get list of reserved Instances?


I can successfully get list of EC2 instance.

using below code

$conf_aws = array();
$conf_aws['credentials']= array(
    'key' => $config['AWS']['configkey'],
    'secret'  => $config['AWS']['configsecret'],
);

$conf_aws['region'] = 'ap-southeast-1';
$conf_aws['version']='latest';
$ec2Client  = \Aws\Ec2\Ec2Client::factory($conf_aws);
$list = $ec2Client->DescribeInstances();

Can anybody suggest how to get list of reserved instance.


Solution

  • Use this edited code and it will work.

    $conf_aws = array();
    $conf_aws['credentials']= array(
        'key' => $config['AWS']['configkey'],
        'secret'  => $config['AWS']['configsecret'],
    );
    
    $conf_aws['region'] = 'ap-southeast-1';
    $conf_aws['version']='latest';
    $ec2Client  = \Aws\Ec2\Ec2Client::factory($conf_aws);
    $list = $ec2->describe_reserved_instances_listing();