-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(aws-kinesisstreams-lambda): Add ability to bring-your-own stream #60
Conversation
…s Stream to this pattern BREAKING CHANGE: DefaultKinesisEventSourceProps was removed from lambda-event-source-mapping-defaults and replaced with KinesisEventSourceProps. This now follows the same behavior as the aws-dynamodb-stream-lambda and aws-s3-lambda patterns (which use DynamoEventSourceProps and S3EventSourceProps instead of EventSourceMappingOptions)
@@ -249,6 +252,16 @@ Object { | |||
], | |||
}, | |||
}, | |||
Object { | |||
"Action": "kinesis:DescribeStream", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add this specific permissions, it looks like it was just missing from the latest snapshot.
import * as s3 from '@aws-cdk/aws-s3'; | ||
|
||
export function DefaultKinesisEventSourceProps(_eventSourceArn: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was only being used by the pattern (which now uses KinesisEventSourceProps
), so I deleted it.
|
||
export function KinesisEventSourceProps(_kinesisEventSourceProps?: KinesisEventSourceProps) { | ||
const defaultKinesisEventSourceProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasoning behind these defaults was:
- TRIM_HORIZON: Same as DynamoDB stream default
- Bisect on error: This is a recent feature added by Lambda (https://aws.amazon.com/about-aws/whats-new/2019/11/aws-lambda-supports-failure-handling-features-for-kinesis-and-dynamodb-event-sources/), and enabling it "breaks the impacted batch of records into two when a function returns an error, and retries them separately. This allows you to easily separate the malformed data record from the rest of the batch, and process the rest of data records successfully"
const stack = new Stack(app, 'test-ks-lambda-stack'); | ||
stack.templateOptions.description = 'Integration Test for aws-kinesisstreams-lambda'; | ||
|
||
const lambdaRole = new iam.Role(stack, 'test-role', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no integration tests for bringing existing resources, so I created this one.
I'm creating a role separately because the default one the CDK creates does not have permission to write to CloudWatch, and that'd cause a warning from cfn_nag ("W58 Lambda functions require permission to write CloudWatch Logs")
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it! Thanks for your contribution!
Issue #, if available: #58
Description of changes: This PR adds the ability to bring an existing Kinesis stream to the
aws-kinesisstreams-lambda
pattern. There's also a breaking change in the pattern interface (described below).BREAKING CHANGE: DefaultKinesisEventSourceProps was removed from lambda-event-source-mapping-defaults and replaced with KinesisEventSourceProps. This now follows the same behavior as the aws-dynamodb-stream-lambda and aws-s3-lambda patterns (which use DynamoEventSourceProps and S3EventSourceProps instead of EventSourceMappingOptions)
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.