Skip to content
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

(lambda-event-sources): on_failure parameter is not supported for SelfManagedKafkaEventSource #19917

Closed
sawalanipawan opened this issue Apr 14, 2022 · 2 comments · Fixed by #19995
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda @aws-cdk/aws-lambda-event-sources bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@sawalanipawan
Copy link

sawalanipawan commented Apr 14, 2022

Describe the bug

As per (https://docs.aws.amazon.com/cdk/api/v1/python/aws_cdk.aws_lambda_event_sources/SelfManagedKafkaEventSource.html
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_lambda_event_sources/SelfManagedKafkaEventSource.html) we can specify on_failure parameter in the SelfManagedKafkaEventSource.

But the CloudFormation stack deployment fails with below error:

"Resource handler returned message: "Invalid request provided: Unsupported 'destinationConfig' parameter for given event source mapping type. (Service: Lambda, Status Code: 400)"

Upon checking the CFN documentation (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-destinationconfig) for AWS::Lambda::EventSourceMapping resource, adding destinationConfig is only supported for 'Stream' event sources, which are DynamoDB and Kinesis.

I spun up a test Kafka cluster and then using CDK I created the lambda function that has self-managed Apache Kafka event source.

        mylambda = lambda_.Function(self, "MyLambda",
            code=lambda_.Code.from_asset("lambda"),
            handler="index.handler",
            runtime=lambda_.Runtime.NODEJS_12_X,
            role=role
        )

        mylambda.add_event_source(SelfManagedKafkaEventSource(
            bootstrap_servers=bootstrap_servers,
            topic=topic,
            batch_size=100,  # default
            starting_position=lambda_.StartingPosition.LATEST,
            vpc=vpc,
            vpc_subnets=ec2.SubnetSelection(
                subnet_type=ec2.SubnetType.PRIVATE
            ),
            security_group=security_group
            on_failure=SqsDlq(dead_letter_queue)
        ))

The cdk synth command ran successfully.
After running the cdk deploy command, the corresponding CFN stack failed with below error:

Resource handler returned message: "Invalid request provided: Unsupported 'destinationConfig' parameter for given event source mapping type. (Service: Lambda, Status Code: 400)

This implies that on_failure parameter is not supported for SelfManagedKafkaEventSource.

Also, on AWS console, if you try adding the Apache Kafka event source, you will not find the On-failure destination option.

But you can see the On-failure destination option for DynamoDB and Kinesis event source.

Expected Behavior

For AWS::Lambda::EventSourceMapping resource, adding DestinationConfig is only supported for 'Stream' event sources, which are DynamoDB and Kinesis.

So, this option should be removed from SelfManagedKafkaEventSource.

Current Behavior

The cdk synth command ran successfully.
After running the cdk deploy command, the corresponding CFN stack failed with below error:

Resource handler returned message: "Invalid request provided: Unsupported 'destinationConfig' parameter for given event source mapping type. (Service: Lambda, Status Code: 400)

Reproduction Steps

        mylambda = lambda_.Function(self, "MyLambda",
            code=lambda_.Code.from_asset("lambda"),
            handler="index.handler",
            runtime=lambda_.Runtime.NODEJS_12_X,
            role=role
        )

        mylambda.add_event_source(SelfManagedKafkaEventSource(
            bootstrap_servers=bootstrap_servers,
            topic=topic,
            batch_size=100,  # default
            starting_position=lambda_.StartingPosition.LATEST,
            vpc=vpc,
            vpc_subnets=ec2.SubnetSelection(
                subnet_type=ec2.SubnetType.PRIVATE
            ),
            security_group=security_group
            on_failure=SqsDlq(dead_letter_queue)
        ))

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

1.152.0 (build 9487b39)

Framework Version

No response

Node.js Version

v16.13.0

OS

Mac

Language

Python

Language Version

No response

Other information

No response

@sawalanipawan sawalanipawan added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 14, 2022
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Apr 14, 2022
@sawalanipawan sawalanipawan changed the title (module name): (short issue description) on_failure parameter is not supported for SelfManagedKafkaEventSource Apr 14, 2022
@kaizencc kaizencc changed the title on_failure parameter is not supported for SelfManagedKafkaEventSource (lambda-event-sources): on_failure parameter is not supported for SelfManagedKafkaEventSource Apr 15, 2022
@kaizencc kaizencc added @aws-cdk/aws-lambda-event-sources p1 effort/small Small work item – less than a day of effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 15, 2022
@kaizencc
Copy link
Contributor

Apologies about this, @sawalanipawan! This is a poor user experience we should rectify

@mergify mergify bot closed this as completed in #19995 Apr 20, 2022
mergify bot pushed a commit that referenced this issue Apr 20, 2022
…EventSources (#19995)

Closes #19917. Seems this was missed in a previous fix: #17965. 

Adding breaking changes to `allowed-breaking-changes.txt` because they never worked in the first place.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] 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*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

StevePotter pushed a commit to StevePotter/aws-cdk that referenced this issue Apr 27, 2022
…EventSources (aws#19995)

Closes aws#19917. Seems this was missed in a previous fix: aws#17965. 

Adding breaking changes to `allowed-breaking-changes.txt` because they never worked in the first place.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] 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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda @aws-cdk/aws-lambda-event-sources bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants