From 2a6f645ea55a0d2e43b1335e7cf4f541c6994918 Mon Sep 17 00:00:00 2001 From: Igor Anic Date: Mon, 6 Dec 2021 16:29:14 +0100 Subject: [PATCH] add setting lambda function memory size --- aws/lambda.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/aws/lambda.go b/aws/lambda.go index 332002fe..d8ba11f7 100644 --- a/aws/lambda.go +++ b/aws/lambda.go @@ -61,6 +61,24 @@ func (l *Lambda) Info(name string) (map[string]string, error) { return nil, err } +func (l *Lambda) SetMemory(name string, mem int) error { + input := lambda.UpdateFunctionConfigurationInput{ + FunctionName: aws.String(name), + MemorySize: aws.Int32(int32(mem)), + } + output, err := l.cli.UpdateFunctionConfiguration(context.Background(), &input) + if err == nil { + return err + } + if output.MemorySize == nil { + return fmt.Errorf("output memory size not found") + } + if int(*output.MemorySize) != mem { + return fmt.Errorf("expected mem %d actual %d", mem, output.MemorySize) + } + return nil +} + func (l *Lambda) Invoke(name string, req, rsp interface{}, headers map[string]string) error { var payload []byte if req != nil {