This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 411
/
Makefile
80 lines (62 loc) · 2.29 KB
/
Makefile
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
AWS_BRANCH ?= dev
STACK_NAME ?= photo-sharing
GRAPHQL_API_ID ?= "UNDEFINED"
APPSYNC_URL ?= "UNDEFINED"
PHOTO_BUCKET ?= "UNDEFINED"
TEMPLATE_NAME = image-processing
target:
$(info ${HELP_MESSAGE})
@exit 0
init: ##=> Install OS deps and dev tools
$(info [*] Initializing...)
@$(MAKE) _install_os_packages
deploy: ##=> Deploy services
$(info [*] Deploying backend...)
# cd lambda-functions/thumbnail && npm install && \
# cd ../extract-image-metadata && npm install && \
# cd ../store-image-metadata && npm install && \
cd cloudformation/ && \
sam build --template ${TEMPLATE_NAME}.serverless.yaml && \
sam package \
--s3-bucket ${DEPLOYMENT_BUCKET_NAME} \
--s3-prefix photo-sharing-app/lambda/ \
--output-template-file packaged.yaml && \
sam deploy \
--template-file packaged.yaml \
--stack-name ${STACK_NAME}-backend-${AWS_BRANCH} \
--capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND \
--parameter-overrides \
PhotoRepoS3Bucket=${PHOTO_BUCKET} \
GraphQLEndPoint=${APPSYNC_URL} \
GraphQLAPIId=${GRAPHQL_API_ID} \
Stage=${AWS_BRANCH} \
--no-fail-on-empty-changeset
#############
# Helpers #
#############
_install_os_packages:
$(info [*] Installing jq...)
yum install jq -y
$(info [*] Upgrading Python SAM CLI and CloudFormation linter to the latest version...)
python3 -m pip install --upgrade --user cfn-lint aws-sam-cli
define HELP_MESSAGE
Environment variables:
These variables are automatically filled at CI time except STRIPE_SECRET_KEY
If doing a dirty/individual/non-ci deployment locally you'd need them to be set
AWS_BRANCH: "dev"
Description: Feature branch name used as part of stacks name; added by Amplify Console by default
DEPLOYMENT_BUCKET_NAME: "a_valid_bucket_name"
Description: S3 Bucket name used for deployment artifacts
GRAPHQL_API_ID: "hnxochcn4vfdbgp6zaopgcxk2a"
Description: AppSync GraphQL ID already deployed
PHOTO_BUCKET: ""
Common usage:
...::: Bootstraps environment with necessary tools like SAM CLI, cfn-lint, etc. :::...
$ make init
...::: Deploy all SAM based services :::...
$ make deploy
...::: Delete all SAM based services :::...
$ make delete
...::: Export parameter and its value to System Manager Parameter Store :::...
$ make export.parameter NAME="/env/service/amplify/api/id" VALUE="xzklsdio234"
endef