-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
209 lines (174 loc) · 8.95 KB
/
Copy pathMakefile
File metadata and controls
209 lines (174 loc) · 8.95 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
.PHONY: build-generator build-bronze build-delta-layer build-ppf-wheel build-glue-jobs build-interlock build-audit build-dashboard-api build-daily-sensor build-dryrun-demo build-dashboard deploy-dashboard upload-glue-scripts build-banking-generator build-banking-consumer build-banking-aggregator build-banking build-iot-generator build-iot-consumer build-iot-aggregator build-iot build-ml-generator build-ml-data-prep build-ml-training build-ml-evaluation build-ml-deployment build-ml build-all tf-init tf-apply tf-destroy clean deploy restart-schedules
GENERATOR_DIR := generator
BRONZE_DIR := bronze_consumer
GLUE_DIR := glue_jobs
BUILD_DIR := build
DEPLOY_DIR := deploy/terraform
PPF_DIR := $(HOME)/code/pyspark-pipeline-framework
ENVIRONMENT := dev
AWS_REGION := ap-southeast-1
build-generator:
@echo "Packaging telecom-generator Lambda..."
@mkdir -p $(BUILD_DIR)
@zip -r $(BUILD_DIR)/telecom-generator.zip $(GENERATOR_DIR) -x '$(GENERATOR_DIR)/__pycache__/*' '*.pyc'
@echo "Built $(BUILD_DIR)/telecom-generator.zip"
build-bronze:
@echo "Packaging bronze-consumer Lambda..."
@mkdir -p $(BUILD_DIR)
@zip -r $(BUILD_DIR)/bronze-consumer.zip $(BRONZE_DIR) -x '$(BRONZE_DIR)/__pycache__/*' '*.pyc'
@echo "Built $(BUILD_DIR)/bronze-consumer.zip"
build-delta-layer:
@echo "Building Delta Lake Lambda layer..."
@scripts/build_delta_layer.sh
build-ppf-wheel:
@echo "Building pyspark-pipeline-framework wheel..."
@mkdir -p $(BUILD_DIR)
@pip wheel --no-deps --wheel-dir $(BUILD_DIR) $(PPF_DIR)
@mv $(BUILD_DIR)/pyspark_pipeline_framework-*.whl $(BUILD_DIR)/ppf.whl
@echo "Built $(BUILD_DIR)/ppf.whl"
build-glue-jobs:
@echo "Packaging glue_jobs module..."
@mkdir -p $(BUILD_DIR)
@zip -r $(BUILD_DIR)/glue_jobs.zip $(GLUE_DIR) -x '$(GLUE_DIR)/__pycache__/*' '*.pyc'
@echo "Built $(BUILD_DIR)/glue_jobs.zip"
upload-glue-scripts:
@echo "Uploading Glue scripts..."
@$(eval BUCKET := $(shell cd $(DEPLOY_DIR) && terraform output -raw telecom_data_bucket))
aws s3 sync $(GLUE_DIR)/ s3://$(BUCKET)/glue_scripts/glue_jobs/ --exclude '__pycache__/*' --exclude '*.pyc'
@echo "Uploaded to s3://$(BUCKET)/glue_scripts/"
build-interlock:
@echo "Building Interlock Lambda binaries..."
@scripts/build_interlock.sh
build-audit:
@echo "Packaging bronze-audit Lambda..."
@mkdir -p $(BUILD_DIR)
@zip -r $(BUILD_DIR)/bronze-audit.zip audit -x 'audit/__pycache__/*' '*.pyc'
@echo "Built $(BUILD_DIR)/bronze-audit.zip"
build-dashboard-api:
@echo "Packaging dashboard-api Lambda..."
@mkdir -p $(BUILD_DIR)/dashboard-api-pkg
@pip install -r lambdas/dashboard_api/requirements.txt -t $(BUILD_DIR)/dashboard-api-pkg --quiet
@cp lambdas/dashboard_api/handler.py $(BUILD_DIR)/dashboard-api-pkg/
@cd $(BUILD_DIR)/dashboard-api-pkg && zip -r ../dashboard-api.zip . -x '*/__pycache__/*' '*.pyc' '*/.dist-info/*'
@rm -rf $(BUILD_DIR)/dashboard-api-pkg
@echo "Built $(BUILD_DIR)/dashboard-api.zip"
build-daily-sensor:
@echo "Packaging daily-sensor Lambda..."
@mkdir -p $(BUILD_DIR)/daily-sensor-pkg
@pip install -r lambdas/daily_sensor/requirements.txt -t $(BUILD_DIR)/daily-sensor-pkg --quiet
@cp lambdas/daily_sensor/handler.py $(BUILD_DIR)/daily-sensor-pkg/
@cd $(BUILD_DIR)/daily-sensor-pkg && zip -r ../daily-sensor.zip . -x '*/__pycache__/*' '*.pyc' '*/.dist-info/*'
@rm -rf $(BUILD_DIR)/daily-sensor-pkg
@echo "Built $(BUILD_DIR)/daily-sensor.zip"
build-dryrun-demo:
@echo "Packaging dryrun-demo Lambda..."
@mkdir -p $(BUILD_DIR)/dryrun-demo-pkg
@pip install -r lambdas/dryrun_demo/requirements.txt -t $(BUILD_DIR)/dryrun-demo-pkg --quiet
@cp lambdas/dryrun_demo/handler.py $(BUILD_DIR)/dryrun-demo-pkg/
@cd $(BUILD_DIR)/dryrun-demo-pkg && zip -r ../dryrun-demo.zip . -x '*/__pycache__/*' '*.pyc' '*/.dist-info/*'
@rm -rf $(BUILD_DIR)/dryrun-demo-pkg
@echo "Built $(BUILD_DIR)/dryrun-demo.zip"
build-dashboard:
@echo "Building dashboard static site..."
@cd dashboard && npm run build
@echo "Dashboard built in dashboard/dist/"
deploy-dashboard:
@echo "Deploying dashboard to S3..."
@$(eval BUCKET := $(shell cd $(DEPLOY_DIR) && terraform output -raw dashboard_bucket_name))
aws s3 sync dashboard/dist/ s3://$(BUCKET) --delete
@echo "Dashboard deployed to s3://$(BUCKET)"
# Banking pipeline build targets
build-banking-generator:
@echo "Packaging banking-generator Lambda..."
@mkdir -p $(BUILD_DIR)/banking-generator-pkg
@cp banking/generator/handler.py $(BUILD_DIR)/banking-generator-pkg/
@cd $(BUILD_DIR)/banking-generator-pkg && zip -r ../banking-generator.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/banking-generator.zip"
build-banking-consumer:
@echo "Packaging banking-consumer Lambda..."
@mkdir -p $(BUILD_DIR)/banking-consumer-pkg
@cp banking/consumer/handler.py $(BUILD_DIR)/banking-consumer-pkg/
@cd $(BUILD_DIR)/banking-consumer-pkg && zip -r ../banking-consumer.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/banking-consumer.zip"
build-banking-aggregator:
@echo "Packaging banking-aggregator Lambda..."
@mkdir -p $(BUILD_DIR)/banking-aggregator-pkg
@cp banking/aggregator/handler.py $(BUILD_DIR)/banking-aggregator-pkg/
@cd $(BUILD_DIR)/banking-aggregator-pkg && zip -r ../banking-aggregator.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/banking-aggregator.zip"
build-banking: build-banking-generator build-banking-consumer build-banking-aggregator
@echo "Banking pipeline Lambda packages built."
# IoT pipeline build targets
build-iot-generator:
@echo "Packaging iot-generator Lambda..."
@mkdir -p $(BUILD_DIR)/iot-generator-pkg
@cp iot/generator/handler.py $(BUILD_DIR)/iot-generator-pkg/
@cd $(BUILD_DIR)/iot-generator-pkg && zip -r ../iot-generator.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/iot-generator.zip"
build-iot-consumer:
@echo "Packaging iot-consumer Lambda..."
@mkdir -p $(BUILD_DIR)/iot-consumer-pkg
@cp iot/consumer/handler.py $(BUILD_DIR)/iot-consumer-pkg/
@cd $(BUILD_DIR)/iot-consumer-pkg && zip -r ../iot-consumer.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/iot-consumer.zip"
build-iot-aggregator:
@echo "Packaging iot-aggregator Lambda..."
@mkdir -p $(BUILD_DIR)/iot-aggregator-pkg
@cp iot/aggregator/handler.py $(BUILD_DIR)/iot-aggregator-pkg/
@cd $(BUILD_DIR)/iot-aggregator-pkg && zip -r ../iot-aggregator.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/iot-aggregator.zip"
build-iot: build-iot-generator build-iot-consumer build-iot-aggregator
@echo "IoT pipeline Lambda packages built."
# ML pipeline build targets
build-ml-generator:
@echo "Packaging ml-generator Lambda..."
@mkdir -p $(BUILD_DIR)/ml-generator-pkg
@cp ml/generator/handler.py $(BUILD_DIR)/ml-generator-pkg/
@cd $(BUILD_DIR)/ml-generator-pkg && zip -r ../ml-generator.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/ml-generator.zip"
build-ml-data-prep:
@echo "Packaging ml-data-prep Lambda..."
@mkdir -p $(BUILD_DIR)/ml-data-prep-pkg
@cp ml/data_prep/handler.py $(BUILD_DIR)/ml-data-prep-pkg/
@cd $(BUILD_DIR)/ml-data-prep-pkg && zip -r ../ml-data-prep.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/ml-data-prep.zip"
build-ml-training:
@echo "Packaging ml-training Lambda..."
@mkdir -p $(BUILD_DIR)/ml-training-pkg
@cp ml/training/handler.py $(BUILD_DIR)/ml-training-pkg/
@cd $(BUILD_DIR)/ml-training-pkg && zip -r ../ml-training.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/ml-training.zip"
build-ml-evaluation:
@echo "Packaging ml-evaluation Lambda..."
@mkdir -p $(BUILD_DIR)/ml-evaluation-pkg
@cp ml/evaluation/handler.py $(BUILD_DIR)/ml-evaluation-pkg/
@cd $(BUILD_DIR)/ml-evaluation-pkg && zip -r ../ml-evaluation.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/ml-evaluation.zip"
build-ml-deployment:
@echo "Packaging ml-deployment Lambda..."
@mkdir -p $(BUILD_DIR)/ml-deployment-pkg
@cp ml/deployment/handler.py $(BUILD_DIR)/ml-deployment-pkg/
@cd $(BUILD_DIR)/ml-deployment-pkg && zip -r ../ml-deployment.zip . -x "__pycache__/*" "*.pyc"
@echo " -> $(BUILD_DIR)/ml-deployment.zip"
build-ml: build-ml-generator build-ml-data-prep build-ml-training build-ml-evaluation build-ml-deployment
@echo "ML pipeline Lambda packages built."
build-all: build-generator build-bronze build-ppf-wheel build-glue-jobs build-interlock build-audit build-dashboard-api build-daily-sensor build-dryrun-demo build-banking build-iot build-ml
@echo "All build artifacts ready in $(BUILD_DIR)/"
tf-init:
cd $(DEPLOY_DIR) && terraform init
tf-apply:
cd $(DEPLOY_DIR) && terraform apply
tf-destroy:
cd $(DEPLOY_DIR) && terraform destroy
restart-schedules:
@echo "Cycling EventBridge schedules..."
@aws events disable-rule --name $(ENVIRONMENT)-telecom-cdr-schedule --region $(AWS_REGION)
@aws events disable-rule --name $(ENVIRONMENT)-telecom-seq-schedule --region $(AWS_REGION)
@sleep 2
@aws events enable-rule --name $(ENVIRONMENT)-telecom-cdr-schedule --region $(AWS_REGION)
@aws events enable-rule --name $(ENVIRONMENT)-telecom-seq-schedule --region $(AWS_REGION)
@echo "EventBridge schedules restarted"
deploy: tf-apply restart-schedules
@echo "Deploy complete — schedules are active"
clean:
rm -rf $(BUILD_DIR)