aws / aws/aws-cdk

(lambda-event-sources): Validate that SQS Queue visibility timeout is larger than Lambda function timeout

Open
#20,527 4 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-sqs feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

Validate that SQS Queue visibility timeout is larger than Lambda function timeout when adding SQS queue as event source to Lambda.

### Use Case

When adding SQS as event source to Lambda, AWS requires Queue visibility timeout to be larger than Lambda timeout, otherwise CloudFormation deployment will fail. At the moment, developer will only find out about this issue during deployment. Instead, CDK should fail at synthesis time if timeout condition is not satisfied.

### Proposed Solution

I had a quick look at the code, and it's not immediately obvious how to implement this, because [the place where binding happens](https://github.com/Gtofig/aws-cdk/blob/master/packages/%40aws-cdk/aws-lambda-event-sources/lib/sqs.ts#L69) uses `IFunction` interface, which does not expose `timeout` property.

If we could add `timeout` property to `IFunction`, then validation could be done in the `bind` method of the `SqsEventSource` class linked above.

I'm happy to implement the fix, but want to hear what people think the right way to implement it would be.

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

1.157.0

### Environment details (OS name and version, etc.)

Ubuntu 20

Contributor guide

Open the contributing guide

Research direction

Start in packages/@aws-cdk/aws-lambda-event-sources/lib/sqs.ts at the SqsEventSource bind method and inspect how its IFunction argument exposes function settings. Determine how the Lambda timeout and SQS visibility timeout can be compared during synthesis without assuming the proposed interface change. Done means synthesis fails when the queue visibility timeout is not larger than the Lambda timeout, instead of leaving the failure to CloudFormation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.