-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
90 lines (75 loc) · 2.58 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
81
82
83
84
85
86
87
88
89
90
.PHONY : help init deploy test clean delete
.DEFAULT: help
# Check for .custom.mk file if exists
CUSTOM_FILE ?= .custom.mk
CUSTOM_EXAMPLE ?= .custom.mk.example
ifneq ("$(wildcard $(CUSTOM_FILE))","")
include $(CUSTOM_FILE)
else ifneq ("$(wildcard $(CUSTOM_EXAMPLE))","")
include $(CUSTOM_EXAMPLE)
else
$(error File `.custom.mk` doesnt exist, please create one.)
endif
help:
@echo "init generate project for local development"
@echo "deploy deploy solution from source"
@echo "test run pre-commit checks"
@echo "clean delete virtualenv and installed libraries"
@echo "delete delete deployed stacks"
# Install local dependencies and git hooks
init: venv
venv/bin/pre-commit install
deploy: package
@printf "\n--> Deploying %s template...\n" $(STACK_NAME)
@sam deploy \
--template-file ./cfn/packaged.template \
--stack-name $(STACK_NAME) \
--region $(AWS_REGION) \
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
--parameter-overrides \
AvailabilityZones=$(AWS_REGION)a,$(AWS_REGION)b \
CreateVPNEndpoint=$(CREATE_VPN_ENDPOINT) \
ServerCertificateArn=$(SERVER_CERT_ARN) \
ClientCertificateArn=$(CLIENT_CERT_ARN) \
DomainAdminPassword=$(DOMAIN_ADMIN_PASSWORD) \
WorkstationAccessCIDR=$(WORKSTATION_ACCESS_CIDR) \
WorkstationConnectionManager=$(WORKSTATION_CONNECTION_MANAGER)
package: build
@printf "\n--> Packaging and uploading templates to the %s S3 bucket ...\n" $(BUCKET_NAME)
@sam package \
--template-file ./cfn/main.template \
--s3-bucket $(BUCKET_NAME) \
--s3-prefix $(STACK_NAME) \
--output-template-file ./cfn/packaged.template \
--region $(AWS_REGION)
build:
@printf "\n--> Building lambda_layers dependencies...\n"
@pip install -r src/layers/PythonLayer/requirements.txt --target src/layers/PythonLayer/python --upgrade
# Package for cfn-publish CI
cfn-publish-package: build
zip -r packaged.zip -@ < ci/include.lst
# virtualenv setup
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || virtualenv venv
. venv/bin/activate; pip install -Ur requirements.txt
touch venv/bin/activate
test:
venv/bin/pre-commit run --all-files
cfn-lint:
@cfn-lint
cfn-nag:
@cfn_nag_scan --input-path ./cfn --template-pattern './.*\.template' --deny-list-path ./cfn_nag_denylist.yaml
.PHONY: version
version:
@bumpversion --dry-run --list cfn/main.template | grep current_version | sed s/'^.*='//
# Cleanup local build
clean:
rm -rf venv
find . -iname "*.pyc" -delete
delete:
@printf "\n--> Deleting %s stack...\n" $(STACK_NAME)
@sam delete \
--stack-name $(STACK_NAME) \
--region $(AWS_REGION) \
--no-prompts