pmagunia
pmagunia

Reputation: 1788

Filter instances based on tag

I'm getting Validation error messages with

$workers = array('Filters' => array(array('Name' => 'Tags', array(array('Key' => 'Name', 'Values' => array('mworker'))))));

$list = $ec2Client->describeInstances($workers);

Error Detail:

[Filters][0][Filter] must be an array of properties. Got a numerically indexed array.'

This is with SDK2

Upvotes: 0

Views: 222

Answers (2)

Danack
Danack

Reputation: 25701

That actually didn't work for me - it seems the correct way to search by tags is:

$response = $ec2->describeInstances(array(
    'Filters' => array(
        array('Name' => 'instance-type', 'Values' => array('m1.small')),
        array('Name' => 'tag-value', 'Key' => 'Name', 'Values' => array('Testing'))
    )
));

Which also has a filter on instance-type to show how they are combined.

Upvotes: 0

pmagunia
pmagunia

Reputation: 1788

Found the correct syntax:

$workers = array(array('Filters' => array('Name' => 'Tags', array('Key' => 'Name', 'Values' => array('mworker')))));

Upvotes: 1

Related Questions