Skip to content

Instantly share code, notes, and snippets.

@beka
Last active October 6, 2023 19:23
Show Gist options
  • Save beka/1322c9c86c0b673c26c532c8042867ab to your computer and use it in GitHub Desktop.
Save beka/1322c9c86c0b673c26c532c8042867ab to your computer and use it in GitHub Desktop.
buildspec.yml file for AWS CodeBuild that builds AWS Lambda (Go) and uploads to the specified S3 bucket
version: 0.2
env:
variables:
S3_BUCKET: bucket-name
PACKAGE: package-name
MAINFILE: main.go
phases:
install:
runtime-versions:
golang: 1.20
commands:
- mkdir -p "/go/src/$(dirname ${PACKAGE})"
- ln -s "${CODEBUILD_SRC_DIR}" "/go/src/${PACKAGE}"
# Print all environment variables
- env
- cd "/go/src/${PACKAGE}"
- go get
pre_build:
commands:
- cd "/go/src/${PACKAGE}"
build:
commands:
# Build app
- CGO_ENABLED=0 go build -o ${PACKAGE} ${MAINFILE}
post_build:
commands:
- echo Build completed on `date`
artifacts:
type: zip
files:
- ${PACKAGE}
name: ${PACKAGE}
namespace-type: NONE
packaging: ZIP
path: /${PACKAGE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment