File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 _ caddyhttp.MiddlewareHandler = (* Lambda )(nil )
3535)
3636
37- const maxLoggedRequestIDLength = 256
37+ const (
38+ maxLoggedRequestIDLength = 256
39+ maxLambdaTimeout = 15 * time .Minute
40+ )
3841
3942func init () {
4043 caddy .RegisterModule (& Lambda {})
@@ -124,7 +127,10 @@ func isInsecureEndpoint(endpoint string) bool {
124127// Validate implements caddy.Validator.
125128func (m * Lambda ) Validate () error {
126129 if m .Timeout < 0 {
127- return errors .New ("timeout must be greater than zero" )
130+ return errors .New ("timeout must not be negative" )
131+ }
132+ if time .Duration (m .Timeout ) > maxLambdaTimeout {
133+ return errors .New ("timeout exceeds Lambda's 15-minute execution limit" )
128134 }
129135 if m .RoleARN == "" && (m .ExternalID != "" || m .SessionName != "" ) {
130136 return errors .New ("external_id and session_name require role_arn" )
Original file line number Diff line number Diff line change @@ -147,9 +147,14 @@ func TestValidate(t *testing.T) {
147147 wantErrorText : "external_id and session_name require role_arn" ,
148148 },
149149 {
150- name : "non-positive timeout" ,
150+ name : "negative timeout" ,
151151 middleware : Lambda {FunctionName : "test-function" , Timeout : - 1 },
152- wantErrorText : "timeout must be greater than zero" ,
152+ wantErrorText : "timeout must not be negative" ,
153+ },
154+ {
155+ name : "timeout exceeds limit" ,
156+ middleware : Lambda {FunctionName : "test-function" , Timeout : caddy .Duration (maxLambdaTimeout + time .Second )},
157+ wantErrorText : "timeout exceeds Lambda's 15-minute execution limit" ,
153158 },
154159 }
155160
You can’t perform that action at this time.
0 commit comments