forked from aws-quickstart/quickstart-ct-newrelic-one
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (30 loc) · 1.24 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
BUCKET_PREFIX := aws-quickstart
KEY_PREFIX := quickstart-ct-newrelic-one
CFT_PREFIX := templates
CFT_DIR := templates
PROFILE ?= default
REGION ?= us-east-1
BUCKET_NAME ?= service_not_defined
BASE = $(shell /bin/pwd)
s3_buckets := $(BUCKET_PREFIX)
TOPTARGETS := all clean package build
SUBDIRS := $(wildcard functions/source/*/.)
ZIP_SUBDIRS := $(wildcard functions/packages/*)
ZIP_FILES := $(shell find $(ZIP_SUBDIRS) -type f -name '*.zip')
$(TOPTARGETS): $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS) $(ARGS) BASE="${BASE}"
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)/$(@) --acl public-read
.PHONY: $(TOPTARGETS) $(SUBDIRS) $(s3_buckets) $(ZIP_FILES)