-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuildspec-prod.yaml
More file actions
38 lines (37 loc) · 1.81 KB
/
buildspec-prod.yaml
File metadata and controls
38 lines (37 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
version: 0.2
env:
variables:
SERVICE_NAME: "python-serverless-template"
parameter-store:
SAM_S3_BUCKET: "/python-serverless-template/build/SAM_S3_BUCKET"
GITHUB_OWNER: "/python-serverless-template/build/GITHUB_OWNER"
GITHUB_REPO: "/python-serverless-template/build/GITHUB_REPO"
GITHUB_TOKEN: "/python-serverless-template/build/GITHUB_TOKEN"
phases:
install:
runtime-versions:
python: 3.7
nodejs: 10
commands:
# Disable SAM TELEMETRY
- export SAM_CLI_TELEMETRY=0
# Give execute permissions to all build scripts
- chmod +x ./tools/build/*.sh
# Install Hub CLI for GitHub
- ./tools/build/hub-installer.sh && PATH=$PATH:/opt/tools/hub/bin
# Installing Python dependencies
- pip3 install -q aws-sam-cli aws-lambda-decorators yq
build:
commands:
# Copy the contract OpenApi 3.0 spec to the S3 bucket, so it can later be transformed into the SAM template
- aws s3 cp api-contract.yaml s3://$SAM_S3_BUCKET/prod/
# Execute packager tool so every lambda gets just the code and dependencies it needs
- ./tools/build/layer_packager.sh
# Build the SAM template
- sam build -s .build
# Package the build
- sam package --s3-bucket $SAM_S3_BUCKET --s3-prefix prod --output-template-file NewSamTemplate.yaml > /dev/null
# Deploy the package
- sam deploy --s3-bucket $SAM_S3_BUCKET --no-fail-on-empty-changeset --s3-prefix prod --capabilities CAPABILITY_NAMED_IAM --template-file NewSamTemplate.yaml --stack-name $SERVICE_NAME-stack --parameter-overrides ServiceName=$SERVICE_NAME S3Bucket=$SAM_S3_BUCKET/prod > /dev/null 2>&1
# Remove all unneeded s3 folders inside SAM_S3_BUCKET
- aws s3 rm s3://$SAM_S3_BUCKET/prod --recursive > /dev/null