Dhar
Dhar

Reputation: 1

Unable to filter on an Instance TAG for describe instance status in boto3

This is what I am looking to achieve - I would like to get a total instance count for all instances whose "instance-status.reachability" status is set to "passed" + I am only interested in instances with a particular tag name.

I am able to filter on instance-status.reachability but unable to filter on the TAG

 instancesWithInitializingStatus = client.describe_instance_status(

                Filters=[
                    {
                        'Name': 'instance-status.reachability',
                        'Values': ['passed']
                    },
                    {
                        'Name': 'tag:LoadTestName', 
                        'Values': ['Jan11_tds-session2-remote-longrun-withloop_1000_202946']
                    }
                ],
)

This is the ERROR I get

Unexpected error : An error occurred (InvalidParameterValue) when calling the DescribeInstanceStatus operation: The filter 'tag:LoadTestName' is invalid

Upvotes: 0

Views: 602

Answers (1)

Marcin
Marcin

Reputation: 238967

describe_instance_status does not support tag-based filters. Instead describe_instances supports them.

Therefore, you have to first use describe_instances to get instances Ids with your tags, and then pass these Ids into describe_instance_status.

Upvotes: 2

Related Questions