SqsEventSourceProps

class aws_cdk.aws_lambda_event_sources.SqsEventSourceProps(*, batch_size=None, enabled=None, max_batching_window=None)

Bases: object

Parameters
  • batch_size (Union[int, float, None]) – The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function. Your function receives an event with all the retrieved records. Valid Range: Minimum value of 1. Maximum value of 10. If maxBatchingWindow is configured, this value can go up to 10,000. Default: 10

  • enabled (Optional[bool]) – If the SQS event source mapping should be enabled. Default: true

  • max_batching_window (Optional[Duration]) – The maximum amount of time to gather records before invoking the function. Valid Range: Minimum value of 0 minutes. Maximum value of 5 minutes. Default: - no batching window. The lambda function will be invoked immediately with the records that are available.

Example:

from aws_cdk.aws_lambda_event_sources import SqsEventSource
# fn is of type Function


queue = sqs.Queue(self, "MyQueue",
    visibility_timeout=Duration.seconds(30),  # default,
    receive_message_wait_time=Duration.seconds(20)
)

fn.add_event_source(SqsEventSource(queue,
    batch_size=10,  # default
    max_batching_window=Duration.minutes(5)
))

Attributes

batch_size

The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

Your function receives an event with all the retrieved records.

Valid Range: Minimum value of 1. Maximum value of 10. If maxBatchingWindow is configured, this value can go up to 10,000.

Default

10

Return type

Union[int, float, None]

enabled

If the SQS event source mapping should be enabled.

Default

true

Return type

Optional[bool]

max_batching_window

The maximum amount of time to gather records before invoking the function.

Valid Range: Minimum value of 0 minutes. Maximum value of 5 minutes.

Default
  • no batching window. The lambda function will be invoked immediately with the records that are available.

Return type

Optional[Duration]