version: 0.2 env: variables: # This S3 bucket will be used to store the packaged Lambda deployment bundle. # Make sure to provide a valid S3 bucket name (it must exist already). # The AWS CodeBuild IAM role must allow write access to it. S3_BUCKET: "pmaddox-public2" PACKAGE: "github.com/aws-samples/lambda-go-samples" phases: install: commands: # AWS Codebuild Go images use /go for the $GOPATH so let's copy our # application source code into that directory structure. - mkdir -p "/go/src/$(dirname ${PACKAGE})" - ln -s "${CODEBUILD_SRC_DIR}" "/go/src/${PACKAGE}" # Print all environment variables (handy for AWS CodeBuild logs) - env # Install golint - go get -u github.com/golang/lint/golint pre_build: commands: # Make sure we're in the project directory within our GOPATH - cd "/go/src/${PACKAGE}" # Fetch all dependencies - go get -t ./... # Ensure code passes all lint tests - golint -set_exit_status # Check the Go code for common problems with 'go vet' - go vet . # Run all tests included with our application - go test . build: commands: # Build our go application - go build -o main # Package our application with AWS SAM - aws cloudformation package --template-file template.yml --s3-bucket ${S3_BUCKET} --output-template-file packaged.yml artifacts: files: - packaged.yml