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
- Control nodeUbuntu 26.04 LTS
- Python3.14.4
- requests2.34.2
- paramiko5.0.0
- TimeAbout 20 min
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.
- pytest9.1.1
- PyYAML6.0.3
- boto3 / botocore1.43.78
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Control node - every script in this path runs here | 2 Core | 4 GB | 50 GB |
This guide includes
Use this for the shape almost every cloud SDK has. This matters because all of it can be tested with no account at all - and a stub that validates what you sent catches more than a live call would.
- separating the two objects boto3 gives you, a client and a resource
- finding where credentials come from, and the two different failures when they or the region are missing
- testing with no account, using a stub that validates what you sent
- handling an error the API returns
- using paginators, and the retries and timeouts boto3 already has built in
Before you start
- guide 25 - credentials, and where they should not live.
- guide 27 - what a paginator is doing for you.
- guide 28 - what boto3's retry config replaces.
-
The two objects boto3 gives you
-
Where credentials come from, and what happens with none
-
And with no region either
-
Testing it with no account at all
-
A stub that validates what you sent
-
An error the API returns
-
Paginators, so you never write the page loop
-
Retries and timeouts, which boto3 has built in