Registry / devops / aws-cdk-aws-lambda-event-sources

aws-cdk-aws-lambda-event-sources

JSON →
library1.204.0pypypi✓ verified 84d ago

Provides event source mappings for AWS Lambda functions in the AWS CDK. Version 1.204.0 is under the AWS CDK v1 (now in maintenance mode). Users should migrate to AWS CDK v2 where this library has been merged into the main `aws-cdk-lib` package.

pip install aws-cdk-aws-lambda-event-sources
INSTALL
IMPORT
SIG · AWS-CDK-AWS-LAMBDA
A
aws-cdk-aws-lambda-event-sources
devopspythonv1.204.0
harness data pending
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()
Debug
Known issues
deprecatedaws-cdk-aws-lambda-event-sources is part of AWS CDK v1, which is in maintenance mode. AWS CDK v1 no longer receives feature updates and only critical security patches. Use CDK v2 with aws-cdk-lib.
fix
Migrate to CDK v2 and use from aws_cdk.aws_lambda_event_sources import ... (now part of aws-cdk-lib).
affects: >=1.0.0
breakingIn CDK v2, the package aws-cdk-aws-lambda-event-sources is not installed separately; all constructs are in aws-cdk-lib. Keep import paths unchanged (from aws_cdk.aws_lambda_event_sources).
fix
Install aws-cdk-lib instead, no need for the separate package.
affects: >=2.0.0
gotchaSqsEventSource by default sets batchSize to 10. For FIFO queues, you must set batchSize <= 10 and enable reportBatchItemFailures.
fix
Set batch_size=10 (or lower) and set report_batch_item_failures=True for FIFO queues.
affects: all
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.
fix
If 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.
fix
Ensure 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.
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
2
Resources
aws-cdk-aws-lambda-event-sources — pip install aws-cdk-aws-lambda-event-sources · libregistry