Search code examples
amazon-ec2boto3

describe_instance_status with boto3 with filter "running" skips instances for region ap-east-1


The following code snippet uses the latest version of boto3 and looks for all "running" instances in ap-east-1, where the client is created with the specific region (ap-east-1)

        try:
            running_instances = ec2.describe_instance_status(
                Filters=[
                    {
                        "Name": "instance-state-name",
                        "Values": ["running"],
                    },
                ],
                InstanceIds=<list of instance_ids>,
            )
        except ClientError as e:
            <catch exception>

The result is an empty list even though there are running Ec2 instances.

The above snippet works for all other regions though.

The AWS command aws ec2 describe-instance-status --region ap-east-1 --filter Name="instance-state-name",Values="running" --instance-id <list of instance ids> returns the running instances with the same filter.

What I am missing for this region specifically while using boto3? Is there a specific version of boto3 that works for ap-east-1 region?


Solution

  • https://github.com/boto/boto3/issues/3575 - I asked the question here and they helped with debugging it.

    Org Payer Level Regional STS needed to be enabled for such regions.