Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set timeout for chalice functions in general

In the documentation of chalice one can see an example of a configuration of a lambda function on aws provisioned by chalice.

The idea is that you can define an app like below:

from chalice import Chalice

app = Chalice(app_name='demotimeout')


@app.route('/')
def index():
    return {'hello': 'world'}

@app.lambda_function()
def test_lambda(event, context):
    return {'hello': 'world'}

And with this app you can set the config.json file like so;

{
  "stages": {
    "dev": {
      "api_gateway_stage": "api",
      "lambda_functions": {
        "test_lambda": {
          "lambda_timeout": 120
        }
      }
    }
  },
  "version": "2.0",
  "app_name": "demotimeout"
}

When you do this, you set the timeout for the test_lambda function.

I was wondering, is it possible to set the timeout of the index function? The one that does not have the @app.lambda_function() decorator but the one that has the @app.route('/') decorator?

like image 338
cantdutchthis Avatar asked Oct 12 '25 08:10

cantdutchthis


2 Answers

Change the config.json file as follow:

 {
  "stages": {
    "dev": {
      "api_gateway_stage": "api"
    }
  },
  "version": "2.0",
  "app_name": "myappname",
  "lambda_memory_size" : 2048,
  "lambda_timeout" : 120
}

No need to use lambda decorator or anything.

like image 93
john Avatar answered Oct 13 '25 21:10

john


If the requirements aren't met when it hits the route in Chalice, it will either fail or pass. There is not a timeout setting in Chalice routing.

There is however a timeout setting in Chalice for the lambdas which an be set in the config.

like image 22
griff4594 Avatar answered Oct 13 '25 22:10

griff4594