Skip to content

Commit d022bf4

Browse files
committed
Update README with event source documentation
1 parent 946ea5e commit d022bf4

File tree

1 file changed

+25
-0
lines changed
  • Libraries/src/Amazon.Lambda.Annotations

1 file changed

+25
-0
lines changed

Libraries/src/Amazon.Lambda.Annotations/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Topics:
2020
- [Amazon S3 example](#amazon-s3-example)
2121
- [SQS Event Example](#sqs-event-example)
2222
- [Application Load Balancer (ALB) Example](#application-load-balancer-alb-example)
23+
- [DynamoDB Event Example](#dynamodb-event-example)
2324
- [Custom Lambda Authorizer Example](#custom-lambda-authorizer-example)
2425
- [HTTP API Authorizer](#http-api-authorizer)
2526
- [REST API Authorizer](#rest-api-authorizer)
@@ -1073,6 +1074,27 @@ The `ALBApi` attribute requires an existing ALB listener. Here is a minimal exam
10731074

10741075
Then your Lambda function references `@MyListener` in the `ALBApi` attribute.
10751076

1077+
## DynamoDB Event Example
1078+
This example shows how to use the `DynamoDBEvent` attribute to set up event source mapping between a DynamoDB stream and a Lambda function.
1079+
1080+
The `DynamoDBEvent` attribute contains the following properties:
1081+
* **Stream** (Required) - The DynamoDB stream ARN or a reference to a DynamoDB table resource prefixed with "@". When using a resource reference, the source generator uses `Fn::GetAtt` to get the `StreamArn`.
1082+
* **ResourceName** (Optional) - The CloudFormation resource name for the event source mapping.
1083+
* **StartingPosition** (Optional) - The position in the stream to start reading. Valid values: `TRIM_HORIZON`, `LATEST`. Default is `LATEST`.
1084+
* **BatchSize** (Optional) - The maximum number of records per batch. Must be between 1 and 10000. Default is 100.
1085+
* **MaximumBatchingWindowInSeconds** (Optional) - Maximum time to gather records before invoking. Must be between 0 and 300.
1086+
* **Enabled** (Optional) - If false, the event source mapping is disabled. Default is true.
1087+
* **Filters** (Optional) - Semicolon-separated filter patterns for event filtering.
1088+
1089+
```csharp
1090+
[LambdaFunction(ResourceName = "DynamoDBStreamHandler", Policies = "AWSLambdaDynamoDBExecutionRole", PackageType = LambdaPackageType.Image)]
1091+
[DynamoDBEvent("@TestTable", ResourceName = "TestTableStream", BatchSize = 100, StartingPosition = "TRIM_HORIZON")]
1092+
public void HandleStream(DynamoDBEvent evnt, ILambdaContext lambdaContext)
1093+
{
1094+
lambdaContext.Logger.Log($"Received {evnt.Records.Count} records");
1095+
}
1096+
```
1097+
10761098
## Custom Lambda Authorizer Example
10771099

10781100
Lambda Annotations supports defining custom Lambda authorizers using attributes. Custom authorizers let you control access to your API Gateway endpoints by running a Lambda function that validates tokens or request parameters before the target function is invoked. The source generator automatically wires up the authorizer resources and references in the CloudFormation template.
@@ -1422,6 +1444,9 @@ parameter to the `LambdaFunction` must be the event object and the event source
14221444
* Sets up event source mapping between the Lambda function and SQS queues. The SQS queue ARN is required to be set on the attribute. If users want to pass a reference to an existing SQS queue resource defined in their CloudFormation template, they can pass the SQS queue resource name prefixed with the '@' symbol.
14231445
* ALBApi
14241446
* Configures the Lambda function to be called from an Application Load Balancer. The listener ARN (or `@ResourceName` template reference), path pattern, and priority are required. The source generator creates standalone CloudFormation resources (TargetGroup, ListenerRule, Lambda Permission) rather than SAM event types.
1447+
* Sets up event source mapping between the Lambda function and SQS queues. The SQS queue ARN is required to be set on the attribute. If users want to pass a reference to an existing SQS queue resource defined in their CloudFormation template, they can pass the SQS queue resource name prefixed with the '@' symbol.
1448+
* DynamoDBEvent
1449+
* Sets up event source mapping between the Lambda function and DynamoDB streams. The stream ARN or table resource reference (prefixed with '@') is required.
14251450

14261451
### Parameter Attributes
14271452

0 commit comments

Comments
 (0)