34

I am new to AWS and Go and I am trying to execute my Lambda function via AWS SAM CLI. But every time I try to do so I get the following error:

I0517 07:51:11.052078      13 main.go:62] Thumbnail Lambda successfully started 
I0517 07:51:13.696304      13 utils.go:99] Needed directories successfully created
2019-05-17 09:51:14 Function 'Thumbnail' timed out after 3 seconds
2019-05-17 09:51:14 Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received:

I did not want to copy information I pass in the HTTP request since its sensitive.

Any idea how I can modify this 3 second timeout?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Stefan Radonjic
  • 1,449
  • 4
  • 19
  • 38
  • 2
    How did you set up your lambda? Via console? SDK? Cloudformation? For all of the above, you can set the value of the timeout. The default is 3 seconds, hence the above error. Edit: ah, you are using the SAM cli? You probably have a template.yaml file in your project. Search for 'Timeout' and check the value – Hieron May 17 '19 at 08:20

3 Answers3

51

The default timeout of Lambda functions is 3 seconds. You can set any value by updating the Timeout property in your SAM template, e.g.

ExampleLambda:
  Type: AWS::Serverless::Function
  Properties:
    CodeUri: .
    Handler: index.handler
    Runtime: nodejs10.x
    Timeout: 10
matsev
  • 32,104
  • 16
  • 121
  • 156
19

I am using template.yml in order to set up my lambda. I forgot to re-build and re-run sam local start-api when I introduced Timeout property to it. Honest mistake, thank you for your time.

Stefan Radonjic
  • 1,449
  • 4
  • 19
  • 38
3

This doesn't pertain to sam local start-api, but if you're developing in PyCharm and running a single Lambda function with the PyCharm run button, there's another setting you might not have seen in the run configuration window where you can specify the timeout:

enter image description here

Tobias Feil
  • 2,399
  • 3
  • 25
  • 41