CertGrid CertGrid
Concepts·Python Automation for IT

Python Cloud SDK Patterns with boto3

boto3 is the shape almost every cloud SDK has: a client per service, one exception class for every failure, paginators instead of page loops, and retries already built in. This guide covers where credentials come from and what happens with none, the region omission that raises against the one that silently sends you to us-east-1, and `botocore.stub.Stubber` - which lets you exercise all of it with no AWS account at all.

APIs and Cloud Guide 30 of 39 Advanced

Written against the versions above. boto3 and botocore 1.43.78. The `resource` API is feature-frozen - new services and features are client-only. `retries` defaults to `mode: legacy` unless `AWS_RETRY_MODE` says otherwise.

Everything on this page runs on the control node. Any machine with Python 3 will do.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSControl node - every script in this path runs here2 Core4 GB50 GB

Before you start

  1. The two objects boto3 gives you

  2. Where credentials come from, and what happens with none

  3. And with no region either

  4. Testing it with no account at all

  5. A stub that validates what you sent

  6. An error the API returns

  7. Paginators, so you never write the page loop

  8. Retries and timeouts, which boto3 has built in

Official sources