-
Notifications
You must be signed in to change notification settings - Fork 6
/
buildspec.yml
86 lines (70 loc) · 3.08 KB
/
buildspec.yml
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
version: 0.2
# Buildspec Reference Doc: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax
#################################
# Runtime Environment Variables #
#################################
# env:
# variables:
# key: "value"
# key: "value"
# parameter-store:
# key: "value"
# key: "value"
phases:
install:
commands:
# Use Install phase to install packages or any pre-reqs you may need throughout the build (e.g. dev deps, security checks, etc.)
- echo "[Install phase]"
- echo "Install the SAM CLI"
- pip install aws-sam-cli
# Install PyTest & libraries
- pip install pytest
- pip install -r sam/requirements.txt
pre_build:
commands:
# Use Pre-Build phase to run tests, install any code deps or any other customization before build
- echo "[Pre-Build phase]"
# PyTest for the Lambdas
- pytest -vv
### FIXME #
# Need to cycle through all Lambda functions in the `sam/api` folder and do pip install for all of them respectively.
# `sam build` does not install the `requirements.txt` for nested Lambda functions so
# we need to manually install them in the pre-build phase and SAM will package each folder up respectively
# with the dependencies inside the folders. See your thread about this on the AWS Developers Slack
###########
# FIXME path finding automatic
- echo "Install dependencies for Lambda functions"
- cd sam/api/get_user_by_id && pip install -r requirements.txt -t "$PWD"
- cd ../../.. # I should be punished for this
build:
commands:
# Use Build phase to build your artifacts (compile, package, etc.)
- echo "[Build phase]"
# We package the SAM template and create `packaged.yaml` file that will be used in our pipeline for deployment
## Here we separate Build from Deployment and segregate permissions for different steps
# - echo "Starting SAM packaging `date` in `pwd`"
# - aws cloudformation package --template-file template.yml --s3-bucket $BUILD_OUTPUT_BUCKET --output-template-file packaged.yml
- echo "Build SAM application `date` in `pwd`"
- sam build --debug
- echo "Deploy SAM Applicaion `date` in `pwd`"
- sam deploy --no-fail-on-empty-changeset --role-arn $SAM_ROLE_ARN
- echo "SAM deploy completed on `date`"
post_build:
commands:
# Use Post Build for notifications, git tags and any further customization after build
# - echo "[Post-Build phase]"
##################################
# Build Artifacts to be uploaded #
##################################
# artifacts:
# files:
# # list of local files relative to this build environment that will be added to the final artifact (zip)
# - packaged.yml
# discard-paths: yes
#########################################
# Cache local files for subsequent runs #
#########################################
# cache:
# paths:
# # List of path that CodeBuild will upload to S3 Bucket and use in subsequent runs to speed up Builds
# # - '/root/.cache/pip'