feat(lambda-event-sources): add AT_TIMESTAMP event source mapping starting position#20741
feat(lambda-event-sources): add AT_TIMESTAMP event source mapping starting position#20741mergify[bot] merged 5 commits intoaws:mainfrom cecheta:at-timestamp
Conversation
kaizencc
left a comment
There was a problem hiding this comment.
Hi @cecheta! Thanks for submitting this PR! I've provided some comments mostly surrounding the documentation around this feature. There's a lot of weird things going on, like the property only being allowed in Kinesis streams and being used in conjunction with AT_TIMESTAMP. So we need to be very careful with the docs.
| * | ||
| * @default Required when startingPosition is AT_TIMESTAMP. | ||
| */ | ||
| readonly startingPositionTimestamp?: number |
There was a problem hiding this comment.
| readonly startingPositionTimestamp?: number | |
| readonly startingPositionTimestamp?: number; |
| /** | ||
| * The time from which to start reading, in Unix time seconds. | ||
| * | ||
| * @default Required when startingPosition is AT_TIMESTAMP. |
There was a problem hiding this comment.
This is not the correct use of default. The @default tag is meant to describe what happens if left blank -- should be @default - no timestamp. The information about when it's required is important, but put that in the regular documentation instead.
| /** | ||
| * The time from which to start reading, in Unix time seconds. | ||
| * | ||
| * @default Required when startingPosition is AT_TIMESTAMP. |
There was a problem hiding this comment.
same comment regarding this @default
There was a problem hiding this comment.
i also see how @default is being used in startingPosition. I consider that wrong also. Would you please change that as well?
| LATEST = 'LATEST', | ||
|
|
||
| /** | ||
| * Start reading from a position defined by a time stamp. |
There was a problem hiding this comment.
This documentation should mention that if supplied, startingPositionTimestamp must be set
| if (props.startingPosition === StartingPosition.AT_TIMESTAMP && !props.startingPositionTimestamp) { | ||
| throw new Error('startingPositionTimestamp must be provided when startingPosition is AT_TIMESTAMP'); | ||
| } |
There was a problem hiding this comment.
what about when startingPositionTimestamp is set but props.startingPosition !== StartingPosition.AT_TIMESTAMP? I think we should throw an error also
There was a problem hiding this comment.
Added another error and a test
|
|
||
| /** | ||
| * Start reading from a position defined by a time stamp. | ||
| * Only supported for Amazon Kinesis streams. |
There was a problem hiding this comment.
what happens when this is set for non Kinesis streams?
There was a problem hiding this comment.
Updated the docs to say that an error will occur
| * Use an Amazon Kinesis stream as an event source for AWS Lambda. | ||
| */ | ||
| export class KinesisEventSource extends StreamEventSource { | ||
| private innerProps: KinesisEventSourceProps; |
There was a problem hiding this comment.
I would prefer you not do this and just pull out the props you're going to use. Looks like just a startingPositionTimestamp is necessary.
| * __retryAttempts__: The maximum number of times a record should be retried in the event of failure. | ||
| * __startingPosition__: Will determine where to being consumption, either at the most recent ('LATEST') record or the oldest record ('TRIM_HORIZON'). 'TRIM_HORIZON' will ensure you process all available data, while 'LATEST' will ignore all records that arrived prior to attaching the event source. | ||
| * __startingPosition__: Will determine where to being consumption. 'LATEST' will start at the most recent record and ignore all records that arrived prior to attaching the event source, 'TRIM_HORIZON' will start at the oldest record and ensure you process all available data, while 'AT_TIMESTAMP' will start reading records from a specified time stamp. | ||
| * __startingPositionTimestamp__: The time stamp from which to start reading. Used in conjunction with __startingPosition__. |
There was a problem hiding this comment.
README needs to mention that AT_TIMESTAMP only works for kinesis streams.
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…rting position (aws#20741) Closes aws#17214 This PR adds `AT_TIMESTAMP` to the `StartingPosition` enum for lambda event source mappings. ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Closes #17214
This PR adds
AT_TIMESTAMPto theStartingPositionenum for lambda event source mappings.All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integto deploy the infrastructure and generate the snapshot (i.e.yarn integwithout--dry-run)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license