Skip to content

Instantly share code, notes, and snippets.

@samkeen
Last active March 19, 2019 20:55
Show Gist options
  • Save samkeen/223264f56a4b3e654177256021f500b5 to your computer and use it in GitHub Desktop.
Save samkeen/223264f56a4b3e654177256021f500b5 to your computer and use it in GitHub Desktop.
env:
variables:
LAMBDA_PKG_BUCKET_PREFIX: mia
phases:
install:
commands:
# Install AWS SAM
- pip install --user aws-sam-cli
- USER_BASE_PATH=$(python -m site --user-base)
- export PATH=$PATH:$USER_BASE_PATH/bin
- sam --version
build:
commands:
# LAMBDA_PKG_BUCKET from CodeBuild Project
- echo "Lambda package bucket is $LAMBDA_PKG_BUCKET"
- export BUCKET=$LAMBDA_PKG_BUCKET
# $LAMBDA_PKG_BUCKET_PREFIX from env: ^Above
- echo "Lambda package bucket prefix is $LAMBDA_PKG_BUCKET_PREFIX"
- export BUCKET_PREFIX=$LAMBDA_PKG_BUCKET_PREFIX
- export SOURCE_TEMPLATE=template.yaml
- export PACKAGED_TEMPLATE=sam-packaged.yaml
- sam package --template-file $SOURCE_TEMPLATE --s3-bucket $BUCKET --s3-prefix $BUCKET_PREFIX --output-template-file $PACKAGED_TEMPLATE
artifacts:
type: zip
files:
- template.yaml
- sam-packaged.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment