Registry /
devops / aws-cdk-aws-lambda-event-sources
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SqsEventSource
✓ from aws_cdk.aws_lambda_event_sources import SqsEventSource
✗ from aws_cdk.aws_lambda_event_sources.sqs import SqsEventSource
The correct top-level module is 'aws_lambda_event_sources'; using submodule path was an older pattern.
SnsEventSource
✓ from aws_cdk.aws_lambda_event_sources import SnsEventSource
✗ from aws_cdk.aws_lambda_event_sources.sns import SnsEventSource (if attempting subpackage)
All event sources are exposed directly in the top-level module.
Creates an SQS queue and a Lambda function, then adds the queue as an event source.
from aws_cdk import core
from aws_cdk.aws_lambda import Function
from aws_cdk.aws_lambda_event_sources import SqsEventSource
from aws_cdk.aws_sqs import Queue
app = core.App()
stack = core.Stack(app, 'MyStack')
queue = Queue(stack, 'MyQueue')
function = Function(stack, 'MyFunction',
runtime=core.aws_lambda.Runtime.PYTHON_3_9,
code=core.aws_lambda.Code.from_inline('def handler(event, context): pass'),
handler='index.handler')
function.add_event_source(SqsEventSource(queue))
app.synth()
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aws_cdk.aws_lambda_event_sources'
The aws-cdk-aws-lambda-event-sources package is not installed, or the CDK version is v2 where the module is part of aws-cdk-lib.
fixIf using CDK v1: pip install aws-cdk-aws-lambda-event-sources. If CDK v2: install aws-cdk-lib (no separate package needed).
jsii.errors.JSIIError: Expected a value of type aws-cdk-lib.aws_lambda_event_sources.SqsEventSource but got ...
The event source class is being constructed incorrectly or imported from a wrong module.
fixEnsure import: from aws_cdk.aws_lambda_event_sources import SqsEventSource; and instantiate with required props only.
Upgrade
Version history
1.204.0latest on PyPI · released Jun 19, 2023
Audit
Dependencies
aws-cdk-liboptionalCDK v2 merged all constructs into a single library; use instead of v1 packages.