AWS Sam Deployed Golang lambda functions runtime error

0

I have golang lambda functions deployed via aws sam. I followed the guide for compiling for the provided.al2 runtime, yet I am getting the following error: Error: fork/exec /var/task/bootstrap: exec format error Runtime.InvalidEntrypoint

Sam Template looks like this:

UserPutFunction:
    Type: AWS::Serverless::Function 
    Metadata:
      BuildMethod: makefile
    Properties:
      CodeUri: ./
      Handler: bootstrap
      Runtime: provided.al2
      Architectures:
        - arm64
      Events:
        CatchAll:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /user
            Method: POST

And the Makefile is this:

build-UserPutFunction:
	set GOOS=linux
	set GOARCH=amd64
	go build -o $(ARTIFACTS_DIR)\bootstrap ./lambda/user/user_put

Am I missing something?

1 Antwort
0

Hello.

The error is caused by a problem with the architecture of the container image.
In this case, amd64 is used in Makefile.
So, I think you need to set Architectures to "x86_64".
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html#sam-function-architectures

UserPutFunction:
    Type: AWS::Serverless::Function 
    Metadata:
      BuildMethod: makefile
    Properties:
      CodeUri: ./
      Handler: bootstrap
      Runtime: provided.al2
      Architectures:
        - x86_64
      Events:
        CatchAll:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /user
            Method: POST
profile picture
EXPERTE
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen