-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
48 lines (32 loc) · 1.36 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
BUCKET_PREFIX := lacework-alliances
KEY_PREFIX := lacework-control-tower-cfn
PACKAGES_PREFIX := lambda/
CFT_PREFIX := templates
CFT_DIR := templates
DATASET := lacework-alliances-prod
PROFILE ?= alliances-admin
REGION ?= us-west-2
BUCKET_NAME ?= service_not_defined
BASE = $(shell /bin/pwd)
s3_buckets := $(BUCKET_PREFIX)
TOPTARGETS := all clean package build
SUBDIRS := $(wildcard lambda_functions/source/*/.)
ZIP_SUBDIRS := $(wildcard lambda_functions/packages/*/.)
ZIP_FILES := $(shell find $(ZIP_SUBDIRS) -type f -name '*.zip')
$(TOPTARGETS): $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS) $(ARGS) BASE="${BASE}" DATASET="${DATASET}"
upload: $(s3_buckets)
$(s3_buckets):
$(info [+] Uploading artifacts to '$@' bucket)
@$(MAKE) _upload BUCKET_NAME=$@
@$(MAKE) _upload_zip BUCKET_NAME=$@
_upload:
$(info [+] Uploading templates to $(BUCKET_NAME) bucket)
@aws --profile $(PROFILE) --region $(REGION) s3 cp $(CFT_DIR)/ s3://$(BUCKET_NAME)/$(KEY_PREFIX)/$(CFT_PREFIX) --recursive --exclude "*" --include "*.yaml" --include "*.yml" --acl public-read
_upload_zip: $(ZIP_SUBDIRS)
$(ZIP_SUBDIRS): $(ZIP_FILES)
$(ZIP_FILES):
$(info [+] Uploading zip files to $(BUCKET_NAME) bucket)
@aws --profile $(PROFILE) --region $(REGION) s3 cp $@ s3://$(BUCKET_NAME)/$(KEY_PREFIX)/$(PACKAGES_PREFIX) --acl public-read
.PHONY: $(TOPTARGETS) $(SUBDIRS) $(s3_buckets) $(ZIP_FILES)