Interview Prep/Python for DevOps/AWS automation with boto3

A script that runs `describe_instances` with 2,000 instance IDs fails with a filter limit error. How do you fix it?

IntermediateScenarioAWS automation with boto3
Answer

Situation read → EC2 limits the number of values in a filter or ID list per request.

What I'd do →

  1. Chunk the IDs into batches (for example 200) and call per batch, or use a paginator with no ID list and filter in Python.
  2. Write a generic chunked() helper and reuse it for other batch-limited APIs (tag_resources max 20 ARNs, delete_objects max 1,000 keys).
for batch in chunked(ids, 200):
    for page in ec2.get_paginator("describe_instances").paginate(InstanceIds=batch): ...

Why → Every batch API has a documented limit; chunking is the standard pattern.

Interview tip → Quote a couple of real limits; it shows hands-on experience.

All Python for DevOps questions Roadmap: Python for automation

More on AWS automation with boto3