Skip to content

Commit 40a25bc

Browse files
committed
add lambda.timeout back, defaulting to 60s. Closes #814
I will leave this undocumented for now since it is an uncommon use-case at the moment, but you can make this whatever you like for background processing by crafting your own Lambda event which looks like a request, bypassing API Gateway
1 parent 2354e3a commit 40a25bc

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

config/lambda.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package config
22

3-
import (
4-
"errors"
5-
)
6-
73
// defaultRuntime is the default runtime.
84
var defaultRuntime = "nodejs10.x"
95

@@ -54,6 +50,10 @@ type Lambda struct {
5450

5551
// Default implementation.
5652
func (l *Lambda) Default() error {
53+
if l.Timeout == 0 {
54+
l.Timeout = 60
55+
}
56+
5757
if l.Memory == 0 {
5858
l.Memory = 512
5959
}
@@ -69,10 +69,6 @@ func (l *Lambda) Default() error {
6969

7070
// Validate implementation.
7171
func (l *Lambda) Validate() error {
72-
if l.Timeout != 0 {
73-
return errors.New(".lambda.timeout is deprecated, use .proxy.timeout")
74-
}
75-
7672
return nil
7773
}
7874

config/lambda_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func TestLambda(t *testing.T) {
1010
c := &Lambda{}
1111
assert.NoError(t, c.Default(), "default")
12-
assert.Equal(t, 0, c.Timeout, "timeout")
12+
assert.Equal(t, 60, c.Timeout, "timeout")
1313
assert.Equal(t, 512, c.Memory, "timeout")
1414
}
1515

platform/lambda/lambda.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ retry:
563563
Runtime: &p.config.Lambda.Runtime,
564564
Role: &p.config.Lambda.Role,
565565
MemorySize: aws.Int64(int64(p.config.Lambda.Memory)),
566-
Timeout: aws.Int64(int64(p.config.Proxy.Timeout + 3)),
566+
Timeout: aws.Int64(int64(p.config.Lambda.Timeout)),
567567
Publish: aws.Bool(true),
568568
Environment: env,
569569
Code: &lambda.FunctionCode{
@@ -627,7 +627,7 @@ func (p *Platform) updateFunction(c *lambda.Lambda, a *apigateway.APIGateway, up
627627
Runtime: &p.config.Lambda.Runtime,
628628
Role: &p.config.Lambda.Role,
629629
MemorySize: aws.Int64(int64(p.config.Lambda.Memory)),
630-
Timeout: aws.Int64(int64(p.config.Proxy.Timeout + 3)),
630+
Timeout: aws.Int64(int64(p.config.Lambda.Timeout)),
631631
Environment: env,
632632
VpcConfig: p.vpc(),
633633
})

0 commit comments

Comments
 (0)