This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 418
/
Makefile
46 lines (35 loc) · 1.48 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
all: backend frontend-build
TEMPLATES = auth product-mock shoppingcart-service
REGION := $(shell python3 -c 'import boto3; print(boto3.Session().region_name)')
ifndef S3_BUCKET
ACCOUNT_ID := $(shell aws sts get-caller-identity --query Account --output text)
S3_BUCKET = aws-serverless-shopping-cart-src-$(ACCOUNT_ID)-$(REGION)
endif
backend: create-bucket
$(MAKE) -C backend TEMPLATE=auth S3_BUCKET=$(S3_BUCKET)
$(MAKE) -C backend TEMPLATE=product-mock S3_BUCKET=$(S3_BUCKET)
$(MAKE) -C backend TEMPLATE=shoppingcart-service S3_BUCKET=$(S3_BUCKET)
backend-delete:
$(MAKE) -C backend delete TEMPLATE=auth
$(MAKE) -C backend delete TEMPLATE=product-mock
$(MAKE) -C backend delete TEMPLATE=shoppingcart-service
backend-tests:
$(MAKE) -C backend tests
create-bucket:
@echo "Checking if S3 bucket exists s3://$(S3_BUCKET)"
@aws s3api head-bucket --bucket $(S3_BUCKET) || (echo "bucket does not exist at s3://$(S3_BUCKET), creating it..." ; aws s3 mb s3://$(S3_BUCKET) --region $(REGION))
amplify-deploy:
aws cloudformation deploy \
--template-file ./amplify-ci/amplify-template.yaml \
--capabilities CAPABILITY_IAM \
--parameter-overrides \
OauthToken=$(GITHUB_OAUTH_TOKEN) \
Repository=$(GITHUB_REPO) \
BranchName=$(GITHUB_BRANCH) \
SrcS3Bucket=$(S3_BUCKET) \
--stack-name CartApp
frontend-serve:
$(MAKE) -C frontend serve
frontend-build:
$(MAKE) -C frontend build
.PHONY: all backend backend-delete backend-tests create-bucket amplify-deploy frontend-serve frontend-build