getlift / lift

Expanding Serverless Framework beyond functions using the AWS CDK
MIT License
912 stars 109 forks source link

Specify Visibility Timeout for SQS other than 6 * function timeout #361

Open johncourt opened 10 months ago

johncourt commented 10 months ago

Start from the Use-case

SQS allows visibility timeout up to 12 hours.

To achieve this I need to set the worker timeout to 2 hours so lift can calculate 6 * 2 = 12 hours. But I want my lambda to time out after a few seconds not 2 hours, wait 12 hours and try again.

Example Config

From the docs:

constructs:
    my-queue:
        # ...
        worker:
            handler: src/worker.handler
            memorySize: 512
            timeout: 10

Implementation Idea

Add an attribute called queueTimeout which overrides the default 6 * worker timeout behaviour

johncourt commented 10 months ago

Great project by the way - avoids a significant limitation with serverless

tampueroc commented 7 months ago

You can configure the SQS Queue VisibilityTimeout Property by adding it as an extension on the construct!

constructs:
    my-queue:
        type: queue
        worker:
            handler: src/worker.handler
        extensions:
            queue:
                Properties:
                    VisibilityTimeout: 43200 # 12 Hours

Sources: