2

I have created an API using AWS SAM and Golang. This API is using an private module, both repos are present on codecommit. My buildspec.yml file is like this :

phases:
  install:
    commands:
      - echo installing SAM ...
      - pip install awscli aws-sam-cli
      # Debugging
      - go env | sort
      - pwd
      - find .

  pre_build:
    commands:
      - echo Installing dependencies ...
      # Fetch all dependencies
      - go clean -modcache
      - GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git
      - echo Installing dependencies done
      - go get ./...

  build:
    commands:
      - echo Build stated on `date`
      - make
      - sam deploy --template-file $PACKGED_TEMPLATE --stack-name $STACK_NAME --capabilities $CAPABILITY --s3-bucket $S3_BUCKET

  post_build:
    commands:
      - echo Deployment completed on `date`

go env | sort result is:

GONOPROXY="git-codecommit.region.amazonaws.com/v1/repos/my-modules"
GONOSUMDB="git-codecommit.region.amazonaws.com/v1/repos/my-modules"
GOOS="linux"
GOPATH="/go:/codebuild/output/src161218396"
GOPRIVATE="git-codecommit.region.amazonaws.com/v1/repos/my-modules"
GOPROXY="https://proxy.golang.org,direct"

Build result is an error:

[Container] 2020/10/22 03:31:20 Running command GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git
go: git-codecommit.region.amazonaws.com/v1/repos/my-modules.git@v1.0.0: reading git-codecommit.region.amazonaws.com/v1/repos/my-modules.git/go.mod at revision v1.0.0: unknown revision v1.0.0

[Container] 2020/10/22 03:31:23 Command did not exit successfully GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git exit status 1

my-modules package is on codecommit and have tag v1.0.0 image

my-modules/go.mod

module git-codecommit.region.amazonaws.com/v1/repos/my-modules.git

go 1.15

require (
    github.com/aws/aws-lambda-go v1.19.1
    github.com/aws/aws-sdk-go v1.35.10
)

Not able to find out the reason for this problem. Looking for some help.

DEV
  • 2,106
  • 3
  • 25
  • 40
  • this line (in *pre_build*) is causing your crash, `- GOSUMDB=off go get git-codecommit.region.amazonaws.com/v1/repos/my-modules.git` get rid of it. – petey Oct 25 '20 at 06:29
  • @petey I had added this line intensely to use GOSUMDB=off. After removing it I am getting same error when go get ./... command executes. – DEV Oct 25 '20 at 14:24
  • I dont believe your git url is correct, please see the answers in this question https://stackoverflow.com/questions/27500861/whats-the-proper-way-to-go-get-a-private-repository (one of them will help you) and update all instances of `git-codecommit.region.amazonaws.com/v1/repos/my-modules.git` to the actual repo url – petey Oct 25 '20 at 16:15

0 Answers0