v3.11.0
Summary
We are excited to announce a new integration for Event Handler to work with AWS AppSync Events APIs. This utility provides a structured way to handle AppSync real-time events through dedicated handler methods, automatic routing, and flexible configuration options.
Our Event Handler REST API now supports customizable HTTP error codes per route. Thanks for this contribution @amin-farjadi.
Additionally, our Data masking utility now supports a broader range of types including Pydantic models, dataclasses, and standard Python classes - an outstanding contribution from @VatsalGoel3.
⭐ Huge thanks to @GuidoNebiolo, @kazu728, @victorperezpiqueras, and @konokenj for their contributions in this release.
New Event Handler for AppSync Events feature
The new AppSyncEventsResolver is designed to streamline working with AWS AppSync real-time APIs by:
- Handling publish and subscribe events with dedicated handler methods
- Routing events automatically based on namespace and channel patterns
- Supporting wildcard patterns for catch-all handlers
- Processing events in parallel (async) or sequentially
- Controlling event aggregation for batch processing
- Implementing graceful error handling
Working with publish events
You can register handlers for publish events using @app.on_publish()
to process and validate messages before they're broadcasted to subscribers. This is useful to modify payload content, apply business logic, and reject messages when needed.
Working with subscribe events
You can use @app.on_subscribe()
to handle subscription requests before allowing clients to listen to specific channels. This enables authorization checks and subscription filtering based on client context or payload attributes, s well as subscription tracking, for example.
Working with aggregated processing
You can use the parameter aggregate=True
to process multiple events together as a batch. This is useful when you need to optimize database operations, or want to have full control over how the messages are processed, for example.
AppSync Events FAQs
Q: Can I handle different types of events from the same channel?
A: Yes, you can register different handlers for publish and subscribe events on the same channel.
Q: How does handler precedence work with wildcard patterns?
A: More specific patterns take precedence over wildcards. For example, /default/channel1
will be chosen over /default/*
, which will be chosen over /*
.
Q: What happens when an exception occurs in my handler?
A: With individual processing (aggregate=False
), the utility catches exceptions and includes them in the response for the specific event while still processing other events. You can also explicitly raise an UnauthorizedException
exception to reject the entire request.
Q: Can I process events asynchronously?
A: Yes, use the @app.async_on_publish()
decorator for asynchronous processing of events.
Q: Does the order of async event processing matter?
A: No, AppSync Events doesn't guarantee delivery order. As long as each response includes the original event ID, AppSync processes them correctly regardless of order.
Q: Can I process multiple events as a batch?
A: Yes, set aggregate=True
to receive all matching events as a batch in your handler.
Changes
- refactor(general): add support for
ruff format
(#6512) by @leandrodamascena - refactor(event_handler): use standard collections for types + refactor code (#6495) by @leandrodamascena
- refactor(e2e-tests): use standard collections for types + refactor code (#6505) by @leandrodamascena
- refactor(tests): use standard collections for types + refactor code (#6497) by @leandrodamascena
- refactor(idempotency): use standard collections for types (#6487) by @leandrodamascena
- refactor(feature_flags): use standard collections for type (#6489) by @leandrodamascena
- refactor(streaming): use standard collections for types (#6483) by @leandrodamascena
- refactor(validation): use standard collections for types (#6491) by @leandrodamascena
- refactor(data_masking): use standard collections for types (#6493) by @leandrodamascena
- refactor(parameters): use standard collections for types (#6481) by @leandrodamascena
- refactor(middleware_factory): use standard collections for types (#6485) by @leandrodamascena
- refactor(event_source): use standard collections for types (#6479) by @leandrodamascena
- refactor(tracer): use standard collections for types (#6473) by @leandrodamascena
- refactor(metrics): use standard collections for types (#6472) by @leandrodamascena
- refactor(batch): use standard collections for types (#6475) by @leandrodamascena
- refactor(logger): use standard collections for types (#6471) by @leandrodamascena
- docs(bedrock): fix BedrockServiceRole in template.yaml (#6436) by @GuidoNebiolo
🌟New features and non-breaking changes
- feat(event_handler): add AppSync events resolver (#6558) by @leandrodamascena
- feat(bedrock): add
openapi_extensions
in BedrockAgentResolver (#6510) by @leandrodamascena - feat(logger): add support for exception notes (#6465) by @leandrodamascena
- feat(event_handler): add extras HTTP Error Code Exceptions (#6454) by @kazu728
- feat(data-masking): add support for Pydantic models, dataclasses, and standard classes (#6413) by @VatsalGoel3
- feat(event_handler): add route-level custom response validation in OpenAPI utility (#6341) by @amin-farjadi
📜 Documentation updates
- docs(event_handler): add docs for AppSync event resolver (#6557) by @leandrodamascena
- docs(event_handler): fix typo in api keys swagger url (#6536) by @victorperezpiqueras
- docs(bedrock_agents): remove Pydantic v1 recommendation (#6468) by @konokenj
- feat(data-masking): add support for Pydantic models, dataclasses, and standard classes (#6413) by @VatsalGoel3
- feat(event_handler): add route-level custom response validation in OpenAPI utility (#6341) by @amin-farjadi
🐛 Bug and hot fixes
- fix(parser): make key attribute optional in Kafka model (#6523) by @Weugene
- fix(logger): warn customers when the ALC log level is less verbose than log buffer (#6509) by @anafalcao
🔧 Maintenance
- chore(deps-dev): bump sentry-sdk from 2.26.1 to 2.27.0 (#6553) by @dependabot[bot]
- chore(deps-dev): bump ruff from 0.11.6 to 0.11.7 (#6555) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.38.1 to 1.38.2 (#6556) by @dependabot[bot]
- chore(deps-dev): bump httpx from 0.25.1 to 0.28.1 (#6554) by @dependabot[bot]
- chore(deps): bump actions/download-artifact from 4.2.1 to 4.3.0 (#6550) by @dependabot[bot]
- chore(deps): bump actions/setup-python from 5.5.0 to 5.6.0 (#6549) by @dependabot[bot]
- chore(deps-dev): bump h11 from 0.14.0 to 0.16.0 (#6548) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-aws-lambda-python-alpha from 2.190.0a0 to 2.191.0a0 (#6543) by @dependabot[bot]
- chore(deps-dev): bump cdklabs-generative-ai-cdk-constructs from 0.1.304 to 0.1.305 (#6545) by @dependabot[bot]
- chore(deps-dev): bump mypy-boto3-appconfigdata from 1.37.0 to 1.38.0 in the boto-typing group (#6541) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk from 2.1010.0 to 2.1012.0 (#6540) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.37.37 to 1.37.38 (#6537) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-aws-lambda-python-alpha from 2.189.1a0 to 2.190.0a0 (#6529) by @dependabot[bot]
- chore(deps): bump pydantic-settings from 2.8.1 to 2.9.1 (#6530) by @dependabot[bot]
- chore(deps-dev): bump cdklabs-generative-ai-cdk-constructs from 0.1.302 to 0.1.304 (#6531) by @dependabot[bot]
- chore(deps-dev): bump cfn-lint from 1.34.0 to 1.34.1 (#6528) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.37.35 to 1.37.37 (#6521) by @dependabot[bot]
- chore(deps-dev): bump ruff from 0.11.5 to 0.11.6 (#6515) by @dependabot[bot]
- chore(deps-dev): bump multiprocess from 0.70.17 to 0.70.18 (#6516) by @dependabot[bot]
- chore(deps-dev): bump mkdocs-material from 9.6.11 to 9.6.12 (#6514) by @dependabot[bot]
- chore(deps): bump squidfunk/mkdocs-material from sha256:23b69789b1dd836c53ea25b32f62ef8e1a23366037acd07c90959a219fd1f285 to sha256:95f2ff42251979c043d6cb5b1c82e6ae8189e57e02105813dd1ce124021a418b in /docs (#6513) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk from 2.1007.0 to 2.1010.0 (#6501) by @dependabot[bot]
- chore(deps-dev): bump cfn-lint from 1.33.2 to 1.34.0 (#6502) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.37.34 to 1.37.35 (#6504) by @dependabot[bot]
- chore(deps-dev): bump sentry-sdk from 2.25.1 to 2.26.1 (#6477) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-lib from 2.189.0 to 2.189.1 (#6461) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-aws-lambda-python-alpha from 2.189.0a0 to 2.189.1a0 (#6462) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.37.33 to 1.37.34 (#6459) by @dependabot[bot]
- chore(deps-dev): bump cdklabs-generative-ai-cdk-constructs from 0.1.301 to 0.1.302 (#6460) by @dependabot[bot]
- chore(deps): bump codecov/codecov-action from 5.4.0 to 5.4.2 (#6458) by @dependabot[bot]
- chore(deps): bump actions/setup-node from 4.3.0 to 4.4.0 (#6457) by @dependabot[bot]
- chore(deps-dev): bump cfn-lint from 1.33.1 to 1.33.2 (#6450) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.37.31 to 1.37.33 (#6449) by @dependabot[bot]
- chore(deps): bump typing-extensions from 4.13.1 to 4.13.2 (#6451) by @dependabot[bot]
- feat(data-masking): add support for Pydantic models, dataclasses, and standard classes (#6413) by @VatsalGoel3
- chore(deps-dev): bump ruff from 0.11.4 to 0.11.5 (#6443) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-aws-lambda-python-alpha from 2.188.0a0 to 2.189.0a0 (#6444) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-lib from 2.188.0 to 2.189.0 (#6445) by @dependabot[bot]
- chore(deps-dev): bump cfn-lint from 1.33.0 to 1.33.1 (#6442) by @dependabot[bot]
- chore(deps-dev): bump boto3-stubs from 1.37.29 to 1.37.31 (#6433) by @dependabot[bot]
- chore(deps-dev): bump aws-cdk-aws-lambda-python-alpha from 2.187.0a0 to 2.188.0a0 (#6434) by @dependabot[bot]
- chore(deps-dev): bump ruff from 0.11.3 to 0.11.4 (#6428) by @dependabot[bot]
- chore(deps-dev): bump pytest-cov from 6.1.0 to 6.1.1 (#6429) by @dependabot[bot]
- chore(deps-dev): bump cfn-lint from 1.32.4 to 1.33.0 (#6430) by @dependabot[bot]
- chore(deps): bump pydantic from 2.11.2 to 2.11.3 (#6427) by @dependabot[bot]
This release was made possible by the following contributors:
@GuidoNebiolo, @VatsalGoel3, @Weugene, @amin-farjadi, @anafalcao, @dependabot[bot], @github-actions[bot], @kazu728, @konokenj, @leandrodamascena, @victorperezpiqueras, dependabot[bot] and github-actions[bot]