Skip to content

Commit

Permalink
Migrate away from deprecated go1.x lambda runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Sep 16, 2024
1 parent b0634ff commit 3939966
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ run-server:
## Compile the server as a lambda function
.PHONY: build-lambda
build-lambda:
GOOS=linux go build -ldflags="-s -w $(LDFLAGS)" -o dist/marketplace-lambda ./cmd/lambda/
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w $(LDFLAGS)" -tags lambda.norpc -o dist/bootstrap ./cmd/lambda/

## Package the lambda binary into a .zip artifact
.PHONY: package-artifact
package-artifact:
zip -j dist/mattermost-marketplace.zip dist/bootstrap

## Deploy the lambda stack
.PHONY: deploy-lambda
deploy-lambda: clean build-lambda
deploy-lambda: clean build-lambda package-artifact
serverless deploy --verbose --stage $(SLS_STAGE)

## Deploy the lambda function only to an existing stack
.PHONY: deploy-lambda-fast
deploy-lambda-fast: clean build-lambda
deploy-lambda-fast: clean build-lambda package-artifact
serverless deploy function -f server --stage $(SLS_STAGE)

## Update plugins.json
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22
toolchain go1.22.6

require (
github.com/akrylysov/algnhsa v0.0.0-20190319020909-05b3d192e9a7
github.com/akrylysov/algnhsa v1.1.0
github.com/blang/semver v3.5.1+incompatible
github.com/google/go-github/v28 v28.0.0
github.com/gorilla/mux v1.8.1
Expand All @@ -19,7 +19,7 @@ require (
)

require (
github.com/aws/aws-lambda-go v1.9.0 // indirect
github.com/aws/aws-lambda-go v1.47.0 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dyatlov/go-opengraph/opengraph v0.0.0-20220524092352-606d7b1e5f8a // indirect
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/akrylysov/algnhsa v0.0.0-20190319020909-05b3d192e9a7 h1:IAPakbB8XIYLWMATOpgH9Nbz7nsR2aRHHXoMHxduXSc=
github.com/akrylysov/algnhsa v0.0.0-20190319020909-05b3d192e9a7/go.mod h1:HhzjNA0EjUWcwHTUMwqrpeAdIF3gRmpH0HpWx1hYJSc=
github.com/akrylysov/algnhsa v1.1.0 h1:G0SoP16tMRyiism7VNc3JFA0wq/cVgEkp/ExMVnc6PQ=
github.com/akrylysov/algnhsa v1.1.0/go.mod h1:+bOweRs/WBu5awl+ifCoSYAuKVPAmoTk8XOMrZ1xwiw=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/aws/aws-lambda-go v1.9.0 h1:r9TWtk8ozLYdMW+aelUeWny8z2mjghJCMx6/uUwOLNo=
github.com/aws/aws-lambda-go v1.9.0/go.mod h1:zUsUQhAUjYzR8AuduJPCfhBuKWUaDbQiPOG+ouzmE1A=
github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI=
github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
Expand Down Expand Up @@ -190,7 +190,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
Expand Down
12 changes: 6 additions & 6 deletions serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ provider:
name: aws
stage: ${opt:stage, 'dev'}
region: us-east-1
runtime: go1.x
runtime: provided.al2023
architecture: x86_64
timeout: 5
memorySize: 512

package:
exclude:
- ./**
include:
- ./dist/**
individually: true

functions:
server:
handler: dist/marketplace-lambda
handler: bootstrap # newer runtimes require that the binary name is bootstrap and present in the root of the zip
# Proxy all HTTP requests to the lambda function
events:
- http:
path: /{proxy+}
method: any
package:
artifact: dist/mattermost-marketplace.zip # override the default artifact to point to the zip file we packaged

resources:
Resources:
Expand Down

0 comments on commit 3939966

Please sign in to comment.