SqsEventSource

class aws_cdk.aws_lambda_event_sources.SqsEventSource(queue, *, batch_size=None, enabled=None, filters=None, max_batching_window=None, max_concurrency=None, report_batch_item_failures=None)

Bases: object

Use an Amazon SQS queue as an event source for AWS Lambda.

ExampleMetadata:

infused

Example:

import aws_cdk.aws_lambda_event_sources as eventsources
import aws_cdk.aws_sqs as sqs

# fn: lambda.Function

queue = sqs.Queue(self, "Queue")
fn.add_event_source(eventsources.SqsEventSource(queue))
Parameters:
  • queue (IQueue) –

  • 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

  • filters (Optional[Sequence[Mapping[str, Any]]]) – Add filter criteria option. Default: - None

  • 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.

  • max_concurrency (Union[int, float, None]) – The maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke. Default: - No specific limit.

  • report_batch_item_failures (Optional[bool]) – Allow functions to return partially successful responses for a batch of records. Default: false

Methods

bind(target)

Called by lambda.addEventSource to allow the event source to bind to this function.

Parameters:

target (IFunction) –

Return type:

None

Attributes

event_source_mapping_arn

The ARN for this EventSourceMapping.

event_source_mapping_id

The identifier for this EventSourceMapping.

queue