aws-amplify / aws-amplify/amplify-cli
Go lambda function fails with `GLIBC_2.32' not found
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v18.14.0
### Amplify CLI Version
11.1.1
### What operating system are you using?
Windows WSL 2
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No
### Describe the bug
I created a go function, then ran `amplify push` to compile and create the lambda function. Everything went smoothly until the function was executed by API Gateway and failed with the error:
```
/var/task/main: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/main)
```
### Expected behavior
The API gateway should return a 200 but instead returns 502 since the lambda function fails.
### Reproduction steps
create a api and lambda function with `amplify add api`.
Create an api with `/search` path.
create a new go function then replace the contents with 👍
```
package main
import (
"context"
"encoding/json"
"fmt"
// "github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kendra"
)
type QueryRequest struct {
Search string `json:"search"`
IndexID string `json:"indexID"`
}
type QueryResponse struct {
Results *kendra.QueryOutput `json:"results`
Documents []Document `json:"documents`
Lawyers []Lawyer `json:"lawyers`
}
/
func handler(ctx context.Context, request QueryRequest) (QueryResponse, error) {
// print out the request
functionrequest, _ := json.Marshal(request)
println("Query Request:\n", string(functionrequest))
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
svc := kendra.New(sess)
println("Started the kendra session")
// 1. Security checks for the requesting user and index
// Skipped for Now
// 2. Query the index with the search term
// Check if the specified index exists
_, err := svc.DescribeIndexWithContext(ctx, &kendra.DescribeIndexInput{
Id: &request.IndexID,
})
if err != nil {
return QueryResponse{}, fmt.Errorf("failed to describe index %s: %v", request.IndexID, err)
}
println("Index exists")
input := &kendra.QueryInput{
QueryText: &request.Search,
IndexId: &request.IndexID,
}
kendraResp, err := svc.QueryWithContext(ctx, input)
if err != nil {
return QueryResponse{}, fmt.Errorf("failed to query index %s: %v", request.IndexID, err)
}
KendraJson, _ := json.Marshal(kendraResp)
println("Query successful:\n", string(KendraJson))
return QueryResponse {}
```
- run `amplify push`
This will cause the error.
However, I also have CICD setup with a github repo with the following build settings:
```
version: 1
backend:
phases:
preBuild:
commands:
- yum install golang -y
- mkdir ~/go_proj
- export PATH=$PATH:/usr/local/go/bin
- export GOPATH=$HOME/go_proj
- export GOBIN=$GOPATH/bin
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- npm ci
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```
when I run `git push`, and the CICD build starts, the error caused by `amplify push` from my local machine is fixed
### Project Identifier
b2a8e45f990b09821ed3bcbcf1838fbc
### Log output
```
# Put your logs below this line
```
### Additional information
_No response_
### Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Contributor guide
Research direction
Start with the Go function path invoked by `amplify add api` and `amplify push`, then compare its local WSL build with the CI `amplifyPush --simple` build. Reproduce the API Gateway invocation and inspect how the resulting binary's GLIBC requirements differ; done means the deployed function runs successfully and the API returns 200.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, go
- Domain
- api, cli, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100