Go modules builder fails when using local module with provisioned.AL2 runtime
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- go
- 領域
- build-system
調査の方向性
提供された provided.al2 テンプレート、関数の go.mod の置換、およびレポートに示されている Makefile を使用して、sam build で障害を再現します。まず CustomMakeBuilder:CopySource と CustomMakeBuilder:MakeBuild のステップから開始し、その後、ローカルの ../models の置換がビルド中も利用可能なままであることを確認します。同じ Go アプリケーションが provided.al2 で正常にビルドできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description:
Using sam build in go projects with a dependency on a local module fails when the function runtime is Runtime: provided.al2
Steps to reproduce the issue:
- create a new go application
sam init --name sam-app --runtime go1.x --dependency-manager mod --app-template hello-world - Create a new module (here is the example I used). In a new folder called models, initialise a new module using
go mod init hello-go/models
add a new go file called person.go add this code
package models
type Person struct {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
}
func (p *Person) FullName() string {
return p.FirstName + " " + p.LastName
}
- Open the main.go file for the hello0world function. Import "hello-go/models" and replace the return statement with this
person := models.Person{FirstName: "John", LastName: "Doe"}
return events.APIGatewayProxyResponse{
Body: fmt.Sprintf("Hello %s, your ip address is %v", person.FullName(), string(ip)),
StatusCode: 200,
}, nil
- Open the function go.mod file and add make sure the dependency is replaced to point to the local module
require (
github.com/aws/aws-lambda-go v1.23.0
hello-go/models v0.0.1
)
module hello-world
go 1.17
replace hello-go/models => ../models
- Build the function
sam build - If you run
sam local invoke "HelloWorldFunction"you should see the output (with your IP address)
{"statusCode":200,"headers":null,"multiValueHeaders":null,"body":"Hello John Doe, your ip address is 127.0.0.1\n"}%
-
Update the sam template to use Amazon Linux 2 instead of the managed runtime.
-
In the function definition replace handler and runtime properties, and the Metadata resource attribute
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello-world/
Handler: bootstrap
Runtime: provided.al2
Tracing: Active # https://docs.aws.amazon.com/lambda/latest/dg/lambda-x-ray.html
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: /hello
Method: GET
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
PARAM1: VALUE
Metadata:
BuildMethod: makefile
- Create a new Makefile in the hello-world function directory and add
build-HelloWorldFunction:
GOOS=linux go build -o bootstrap
cp ./bootstrap $(ARTIFACTS_DIR)/.
- Run
sam build. The build now fails.
Observed result:
sam build
Building codeuri: /Users/sliedig/go/src/hello-go-al2/hello-world runtime: provided.al2 metadata: {'BuildMethod': 'makefile'} functions: ['HelloWorldFunction']
Running CustomMakeBuilder:CopySource
Running CustomMakeBuilder:MakeBuild
Current Artifacts Directory : /Users/sliedig/go/src/hello-go-al2/.aws-sam/build/HelloWorldFunction
Build Failed
Error: CustomMakeBuilder:MakeBuild - Make Failed: main.go:9:2: hello-go-al2/models@v0.0.1: replacement directory ../models does not exist
make[1]: *** [build-HelloWorldFunction] Error 1
make: *** [build] Error 1
Expected result:
I would expect the sam build system to correctly build my application irrespective of whether I am using go as a managed runtime or on AL2.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
OS: Darwin x64 20.6.0
go version go1.17.1 darwin/amd64
SAM CLI, version 1.32.0
- 主要言語
- Python
- スター
- 381
- フォーク
- 162
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 2
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws/aws-lambda-builders のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws/aws-lambda-builders#925 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 64/100
aws/aws-lambda-builders#924 · コメント 1 件 · リアクション 1 件 ·
-
Bug: PythonUvBuilder fails to build app with dependencies on editable installs in the workspace オープンstage/needs-triage
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
aws/aws-lambda-builders#892 ·
-
stage/needs-triage type/feature
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
aws/aws-lambda-builders#839 · コメント 2 件 · リアクション 1 件 ·
-
area/build contributors/good-first-issue contributors/welcome type/feature
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
aws/aws-lambda-builders#831 · コメント 3 件 ·
aws/aws-lambda-builders の issue をすべて見る
似ている issue
-
area: harness bug status: needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Human-Agent-Society/reef#625 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
learningequality/kolibri#15351 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Name consistency オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eellak/triplestore#65 · コメント 1 件 ·