Testing Against AWS APIs
summary
Code uses Go and the AWS SDK to call EC2 DescribeInstances; goal is deterministic tests without hitting live AWS. Refactor functions to accept the generated ec2 API interface (eg ec2iface.EC2API) instead of a session, implement a small mock client that returns crafted DescribeInstancesOutput populated with specific instance IDs, and run table-driven tests that assert exact results. The mock carries an instanceIDs field so tests control returned values; the approach compiles and reproduces expected outputs.
AI-written summary · about
chapters (13)
- 0:00Intro
- 0:25Writing code that interacts with AWS
- 0:38Testing code against live systems
- 1:37EC2 API
- 1:56AWS API Patterns
- 2:32API Documentation
- 2:51API Testing
- 3:15Special Sauce
- 3:38API Clients
- 4:28Test Code
- 4:46Mock Client
- 5:36Test
- 5:48Live Demo
related talks
48mClimbing the Testing Pyramid: From Real Service to Interface Mocks in Go
13mAWS for Testing – Top 3 Use Cases
46mInfrastructure testing - it's a real thing!
46mOperating EDA with Quality in Mind
43mBest practices for continuous testing and observability
33mSymmetric API Testing
23mBeyond unit tests: Contributing high level tests for Amazon ECS
01h 32mTesting in Go: 101
