I have an old .Net lambda, that no longer works, because the runtime was outdated years ago. So I decided to rewrite it in Go.
The code migration is pretty simple, but when I try to build and zip it, the result is almost 9 MB. .Net version was only 600 Kb.
Do I need to optimize it somehow? Will it affect the start time of lambda?
I already removed all extra dependencies - at the moment it is
require (
github.com/aws/aws-lambda-go v1.48.0
github.com/aws/aws-sdk-go-v2 v1.36.3
github.com/aws/aws-sdk-go-v2/config v1.29.14
github.com/aws/aws-sdk-go-v2/service/dynamodb v1.43.1
github.com/stretchr/testify v1.10.0
)
require (
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/endpoint-discovery v1.10.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
github.com/aws/smithy-go v1.22.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
I don't think it will affect the cold start period of lambda as you have already installed bundle present. If you were to install at runtime, then the cold start would be longer.
Sometimes packages in a different language can be heavier. The best you can do is use libraries that are lighter and then there is scope for reducing size. However this 9MB size is also fine, no issues with that. We have deployed code much heavier than this and it was not slow.