mthenw / serverless-go-plugin

⚡️ Serverless Framework plugin that compiles Go functions on the fly. Sponsored by https://cloudash.dev
https://cloudash.dev
MIT License
103 stars 17 forks source link

Couldn't find valid bootstrap(s) error #44

Open ronberna opened 1 year ago

ronberna commented 1 year ago

Hello. I'm trying to update the runtime for serverless function from go.1x to provided.al2 using the serverless-go-plugin. I have the following configuration which deploys fine, but during runtime I get:

Error: Couldn't find valid bootstrap(s): [/var/task/bootstrap /opt/bootstrap] Runtime.InvalidEntrypoint

My serverless.yaml file basically looks like: `... provider: name: aws runtime: provided.al2 architecture: arm64 ... plugins:

I converted a different serverless function runtime from go1.x to provided.al2 using similar configuration which works. The only difference between the functions is that the one that works is using aws-sdk-go-v2 while this one, which is not working, is using aws-sdk-go. Would the version of aws-sdk-go cause this error? Any help on this would be greatly appreciated.

ronberna commented 1 year ago

So tried updating my code to use aws-sdk-go-v2, but still getting the same error. After checking my S3 serverless deployment bucket, I'm seeing that the .zip file for the lambda does not contain the bootstrap file (which is the problem). Shouldn't the buildProvidedRuntimeBootstrap setting take care of this?

junwen-k commented 10 months ago

So tried updating my code to use aws-sdk-go-v2, but still getting the same error. After checking my S3 serverless deployment bucket, I'm seeing that the .zip file for the lambda does not contain the bootstrap file (which is the problem). Shouldn't the buildProvidedRuntimeBootstrap setting take care of this?

I believe it is not caused by aws-sdk-go-v2 as I am using the SDK just fine. Suspect that you might missed out

...
provider:
  architecture: arm64
  runtime: provided.al2
...

in your serverless.yml config.

This is a minimal serverless.yml config based on the config I used, and it seems to be working fine.

service: my-service

frameworkVersion: ^3.34

provider:
  name: aws
  architecture: arm64
  runtime: provided.al2
  stage: ${opt:stage, 'dev'}
  region: ${opt:region, 'ap-southeast-1'}

custom:
  go:
    supportedRuntimes: ['provided.al2']
    buildProvidedRuntimeAsBootstrap: true
    # Excluding the RPC reduces the size of the deployment package.
    # See https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html#golang-package-mac-linux-al2.
    cmd: GOARCH=arm64 GOOS=linux go build -tags lambda.norpc -ldflags="-s -w"

plugins:
  - serverless-go-plugin

functions:
  note:
    handler: ./cmd/handlers/note # cmd/handlers/note/main.go, cmd/handlers/note/create.go, etc.
    events:
      - httpApi:
          method: POST
          path: /v1/notes
      - httpApi:
          method: GET
          path: /v1/notes
      - httpApi:
          method: GET
          path: /v1/notes/{id}
      - httpApi:
          method: DELETE
          path: /v1/notes/{id}

Note that I've modified the config based on my existing ones so it might not be perfect, but you should get an idea. Hope that helps :)