Optum / dce

Disposable Cloud Environment
Apache License 2.0
304 stars 80 forks source link

Lambda go1.x runtime deprecated #483

Open gjwillso opened 3 months ago

gjwillso commented 3 months ago

As documented in the below link, the lambda go1.x runtime has now been deprecated by AWS, the provided.al2023 runtime should be used instead. https://aws.amazon.com/blogs/compute/migrating-aws-lambda-functions-from-the-go1-x-runtime-to-the-custom-runtime-on-amazon-linux-2/

This causes the deployment to fail: https://github.com/Optum/dce/blob/06a0c25721f92f08335e1c44e63948d025d56f68/modules/lambda/lambda.tf#L4

moellr commented 3 months ago

A possible quickfix is:

File dce/modules/lambda/lambda.tf (lines 4-5):

OLD:

  runtime       = "go1.x"
  handler       = var.handler

NEW:

  runtime       = "provided.al2"
  handler       = "bootstrap"

File scripts/build.sh (lines 26-30):

OLD:

    GOARCH=amd64 GOOS=linux go build -v -o ../../../bin/lambda/$mod_name
    cd ../../..
    zip -j --must-match \
      bin/lambda/$mod_name.zip \
      bin/lambda/$mod_name

NEW:

    GOARCH=amd64 GOOS=linux go build -v -o ../../../bin/lambda/bootstrap
    cd ../../..
    zip -j --must-match \
      bin/lambda/$mod_name.zip \
      bin/lambda/bootstrap

Tested it myself today on v0.34.1, works.

rbunny87 commented 1 month ago

@moellr tried your solution, deployed successfully but getting error in lambda execution in /api/auth

INIT_REPORT Init Duration: 0.25 ms Phase: invoke Status: error Error Type: Runtime.InvalidEntrypoint START RequestId: 60323ffe-d998-4121-84c2-13fe13fc9324 Version: $LATEST RequestId: 60323ffe-d998-4121-84c2-13fe13fc9324 Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap] Runtime.InvalidEntrypoint END RequestId: 60323ffe-d998-4121-84c2-13fe13fc9324 REPORT RequestId: 60323ffe-d998-4121-84c2-13fe13fc9324 Duration: 2.72 ms Billed Duration: 3 ms Memory Size: 128 MB Max Memory Used: 2 MB

Any help is appreciated...