cdkpatterns (16 Part Series)
This is a pattern adapted from "The Circuit Breaker" by Jeremy Daly. I used EventBridge to route service call failures to a lambda that inserts them into DynamoDB with a 60 second Lifespan. Then when consumers call the API Gateway to call our external service we check if the number of errors in the last 60 seconds is above our threshold. If it is, we instantly error saving lambda execution costs and user time.
This pattern is available in Python/TypeScript AWS CDK versions but also each version has the native CloudFormation checked in as template.yaml.