-
Notifications
You must be signed in to change notification settings - Fork 27
/
Makefile
507 lines (457 loc) · 33.8 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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
ifneq ("$(wildcard .env)","")
include .env
export
endif
# =================================================================
# = Utility targets ===============================================
# =================================================================
NO_COLOR := \x1b[0m
OK_COLOR := \x1b[32;01m
ERROR_COLOR := \x1b[31;01m
WARN_COLOR := \x1b[33;01m
# ===================================================================================================
# Allows a target to require environment variables to exist
# Example that will only run 'mytarget' when the environment variable named 'SERVER' has been set:
# mytarget: env-SERVER another-dependency
# ===================================================================================================
env-%:
@if [ "${${*}}" = "" ]; then \
printf "$(ERROR_COLOR)"; \
echo "**** ERROR: Required environment variable $* not set ****"; \
printf "$(NO_COLOR)"; \
echo; \
exit 1; \
fi
clean:
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Cleaning up" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
rm -rf apollo/dist apollo/node_modules apollo/src/generated apollo/schema/generated prisma/node_modules
init: clean apollo-build
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Done initializing Prisma" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
docker-stop-all:
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Stopping all Docker containers" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
-docker stop $(docker ps -q)
docker-clean: docker-stop-all
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deep cleaning your Docker environment" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
-docker container rm $$(docker container ls -aq)
-docker system prune -f
local-up: apollo-build
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Bringing up Prismatopia" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
docker-compose up --abort-on-container-exit
lint: apollo-lint
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Linting Complete" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
coverage: apollo-coverage
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Coverage Run Complete" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
# =================================================================
# = Prisma targets ================================================
# =================================================================
prisma-generate:
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Generating Prisma schema" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
cd prisma && yarn install && yarn generate
local-prisma-deploy: env-PRISMA_ENDPOINT env-PRISMA_SECRET env-PRISMA_MANAGEMENT_API_SECRET
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying Prisma schema" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
cd prisma && yarn install && yarn deploy
local-prisma-deploy-force: env-PRISMA_ENDPOINT env-PRISMA_SECRET env-PRISMA_MANAGEMENT_API_SECRET
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Forcing deployment of Prisma schema" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
cd prisma && yarn install && yarn deploy --force
local-prisma-reseed: env-PRISMA_ENDPOINT env-PRISMA_SECRET
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Reeseeding Prisma deployment" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
cd prisma && yarn install && yarn reseed
local-prisma-token: env-PRISMA_ENDPOINT env-PRISMA_SECRET
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Generating Prisma token" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)"
cd prisma && yarn install && yarn token
# =================================================================
# = Apollo targets ================================================
# =================================================================
apollo-yarn-install: prisma-generate
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Checking Apollo Yarn packages " && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)" && \
cd apollo && yarn install
apollo-build: env-APOLLO_CONTAINER_IMAGE apollo-yarn-install prisma-generate apollo-lint
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Building Apollo container image: $${APOLLO_CONTAINER_IMAGE}" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)" && \
cd apollo && yarn install && docker build -t $${APOLLO_CONTAINER_IMAGE} .
apollo-lint: apollo-yarn-install
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Linting Apollo " && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)" && \
cd apollo && yarn lint
apollo-coverage: apollo-yarn-install
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Creating test coverage report for Apollo " && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)" && \
cd apollo && yarn coverage
apollo-push: env-APOLLO_CONTAINER_IMAGE apollo-build
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Pushing Apollo container image: $${APOLLO_CONTAINER_IMAGE}" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)" && \
cd apollo && docker push $${APOLLO_CONTAINER_IMAGE}
apollo-token: env-APOLLO_TOKEN_ENDPOINT env-APOLLO_CLIENT_ID env-APOLLO_CLIENT_SECRET
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Grabbing token from: $${APOLLO_TOKEN_ENDPOINT}" && \
printf "%s\n" "======================================================================================" && \
printf "$(NO_COLOR)" && \
curl -s \
--url $${APOLLO_TOKEN_ENDPOINT} \
--header 'accept: application/json' \
--header 'content-type: application/x-www-form-urlencoded' \
--data grant_type=password \
--data scope=openid \
--data-urlencode username=$${APOLLO_TEST_USERNAME} \
--data-urlencode password=$${APOLLO_TEST_PASSWORD} \
-u $${APOLLO_CLIENT_ID}:$${APOLLO_CLIENT_SECRET}
# =================================================================
# = AWS targets ===================================================
# =================================================================
# =================================================================
# Check that the AWS CLI is installed and configured
# =================================================================
aws-cli-check:
@printf "$(WARN_COLOR)"
@printf "%s\n" "======================================================================================"
@printf "%s\n" "= Attention!!"
@printf "%s\n" "= The following actions will be performed against this application:"
@printf "%s\n" "= Application: $(APPLICATION_NAME)"
@printf "%s\n" "= Parameters: aws.$(APPLICATION_NAME)"
@printf "%s\n" "======================================================================================"
@printf "$(NO_COLOR)"
@( read -p "Are you sure you want to continue? [y/N]: " sure && case "$$sure" in [yY]) true;; *) false;; esac )
# =================================================================
# Show a banner before running targets for the whole application
# TODO: aws iam get-user && aws iam list-account-aliases
# =================================================================
aws-app-banner: aws-cli-check env-APPLICATION_NAME
@printf "$(WARN_COLOR)"
@printf "%s\n" "======================================================================================"
@printf "%s\n" "= Attention!!"
@printf "%s\n" "= The following actions will be performed against this application:"
@printf "%s\n" "= Application: $(APPLICATION_NAME)"
@printf "%s\n" "= Parameters: aws.$(APPLICATION_NAME)"
@printf "%s\n" "======================================================================================"
@printf "$(NO_COLOR)"
@( read -p "Are you sure you want to continue? [y/N]: " sure && case "$$sure" in [yY]) true;; *) false;; esac )
# =================================================================
# Provisions IAM resources for the application
# =================================================================
aws-deploy-app-iam: aws-app-banner
@export STACK_NAME=$(APPLICATION_NAME)-iam && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/app-iam.cf.yaml \
--stack-name $${STACK_NAME} \
--capabilities CAPABILITY_IAM \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME)
# =================================================================
# Deploys the application specific network resources to AWS
# =================================================================
aws-deploy-app-network: aws-app-banner
@export STACK_NAME=$(APPLICATION_NAME)-network && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "$(WARN_COLOR)" && \
printf "%s\n" "= Note: This will create a hosted zone for your domain. You may need to stop here and" && \
printf "%s\n" "= update your domain registrar with the name servers for this hosted zone." && \
printf "$(OK_COLOR)" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/app-network.cf.yaml \
--stack-name $${STACK_NAME} \
--capabilities CAPABILITY_IAM \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME)
# =================================================================
# Show a banner before running targets for a specific environment
# =================================================================
aws-env-banner: env-APPLICATION_NAME env-ENVIRONMENT_NAME
@printf "$(WARN_COLOR)"
@printf "%s\n" "======================================================================================"
@printf "%s\n" "= Attention!!"
@printf "%s\n" "= This command is going to be executed in the following AWS environment:"
@printf "%s\n" "= Application: $(APPLICATION_NAME)"
@printf "%s\n" "= Environment: $(ENVIRONMENT_NAME)"
@printf "%s\n" "= Parameters: aws.$(APPLICATION_NAME)"
@printf "%s\n" "= aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME)"
@printf "%s\n" "======================================================================================"
@printf "$(NO_COLOR)"
@( read -p "Are you sure you want to continue? [y/N]: " sure && case "$$sure" in [yY]) true;; *) false;; esac )
# ===========================================================================
# Provision DNS resources for the environment
# ===========================================================================
aws-deploy-env-dns: aws-env-banner
@export STACK_NAME=$(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-dns && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/env-dns.cf.yaml \
--stack-name $${STACK_NAME} \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME) environment=$(ENVIRONMENT_NAME)
# ===========================================================================
# Provision SSL certificate for the environmnet
# ===========================================================================
aws-deploy-env-certificate: aws-env-banner
@export STACK_NAME=$(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-certificate && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "$(WARN_COLOR)" && \
printf "%s\n" "= Note: You need to verify the certificate deployed by this step in the AWS console" && \
printf "%s\n" "= before you continue." && \
printf "%s\n" "= TODO: https://github.com/binxio/cfn-certificate-provider" && \
printf "$(OK_COLOR)" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/env-certificate.cf.yaml \
--stack-name $${STACK_NAME} \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME) environment=$(ENVIRONMENT_NAME)
# ===========================================================================
# Provision network resources for the environment
# ===========================================================================
aws-deploy-env-network: aws-env-banner
@export STACK_NAME=$(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-network && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/env-network.cf.yaml \
--stack-name $${STACK_NAME} \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME) environment=$(ENVIRONMENT_NAME)
# ===========================================================================
# Provision database resources for the environment
# ===========================================================================
aws-deploy-env-db: aws-env-banner
@export STACK_NAME=$(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-db && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/env-db.cf.yaml \
--stack-name $${STACK_NAME} \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME) environment=$(ENVIRONMENT_NAME)
# ===========================================================================
# Provisions the Prisma service for the environment
# ===========================================================================
aws-deploy-env-prisma: aws-env-banner
@export STACK_NAME=$(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-prisma && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/env-prisma.cf.yaml \
--stack-name $${STACK_NAME} \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME) environment=$(ENVIRONMENT_NAME)
# ===========================================================================
# Provisions the Apollo service for the environment
# ===========================================================================
aws-deploy-env-apollo: aws-env-banner apollo-push
@export STACK_NAME=$(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-apollo && \
export STACK_PARAMETERS="$$(cat aws.$(APPLICATION_NAME) aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | tr '\n' ' ')" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying CloudFormation stack $${STACK_NAME}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
aws cloudformation deploy \
--no-fail-on-empty-changeset \
--template-file aws/env-apollo.cf.yaml \
--stack-name $${STACK_NAME} \
--parameter-overrides $${STACK_PARAMETERS} \
--tags poweredby=prismatopia application=$(APPLICATION_NAME) environment=$(ENVIRONMENT_NAME)
# ===========================================================================
# Deploys all of the application level AWS resources in the proper order
# ===========================================================================
aws-deploy-app: aws-deploy-app-iam aws-deploy-app-network
@echo
@echo ======================================================================================
@echo Finished deploying all application level AWS resources
@echo ======================================================================================
# ===========================================================================
# Deploys all of the environment level AWS resources in the proper order
# ===========================================================================
aws-deploy-env: aws-deploy-env-dns aws-deploy-env-certificate aws-deploy-env-network aws-deploy-env-db aws-deploy-env-prisma aws-prisma-deploy apollo-push aws-deploy-env-apollo aws-apollo-update-service
@echo
@echo ======================================================================================
@echo Finished deploying all environment level AWS resources
@echo ======================================================================================
# ===========================================================================
# Retrieves the Prisma secret for the AWS deployed Prisma management API
# ===========================================================================
AWS_PRISMA_MANAGEMENT_API_SECRET_ARN_EXPORT := $(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-PrismaManagementAPISecret
AWS_PRISMA_MANAGEMENT_API_SECRET_ARN := $$(aws cloudformation list-exports --query "Exports[?Name=='$(AWS_PRISMA_MANAGEMENT_API_SECRET_ARN_EXPORT)'].Value" --output text)
AWS_PRISMA_MANAGEMENT_API_SECRET := $$(aws secretsmanager get-secret-value --secret-id $(AWS_PRISMA_MANAGEMENT_API_SECRET_ARN) --query 'SecretString' --output text)
aws-prisma-management-secret: aws-env-banner
@echo PRISMA_MANAGEMENT_API_SECRET: $$(AWS_PRISMA_MANAGEMENT_API_SECRET)
# ===========================================================================
# Retrieves the Prisma secret for the AWS deployed service
# ===========================================================================
AWS_PRISMA_SERVICE_API_SECRET_ARN_EXPORT := $(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-PrismaServiceAPISecret
AWS_PRISMA_SERVICE_API_SECRET_ARN := $$(aws cloudformation list-exports --query "Exports[?Name=='$(AWS_PRISMA_SERVICE_API_SECRET_ARN_EXPORT)'].Value" --output text)
AWS_PRISMA_SERVICE_API_SECRET := $$(aws secretsmanager get-secret-value --secret-id $(AWS_PRISMA_SERVICE_API_SECRET_ARN) --query 'SecretString' --output text)
aws-prisma-service-secret: env-ENVIRONMENT_NAME aws-env-banner
@echo PRISMA_SERVICE_API_SECRET_ARN_EXPORT: $(AWS_PRISMA_SERVICE_API_SECRET_ARN_EXPORT) && \
echo PRISMA_SERVICE_API_SECRET_ARN: $(AWS_PRISMA_SERVICE_API_SECRET_ARN) && \
echo PRISMA_SERVICE_API_SECRET: $(AWS_PRISMA_SERVICE_API_SECRET)
# ===========================================================================
# Gets a token for connecting to the AWS Prisma API
# ===========================================================================
aws-prisma-token: aws-env-banner
@export $$(cat aws.$(APPLICATION_NAME) | grep -v "#" | xargs) && \
export $$(cat aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | grep -v "#" | xargs) && \
export PRISMA_MANAGEMENT_API_SECRET="$(AWS_PRISMA_MANAGEMENT_API_SECRET)" && \
export PRISMA_SECRET="$(AWS_PRISMA_SERVICE_API_SECRET)" && \
export PRISMA_ENDPOINT="https://prisma.$${ApplicationDomainNamespace}" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Getting Prisma API token for $${PRISMA_ENDPOINT}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)\n" && \
cd prisma && yarn token
# ===========================================================================
# Runs Prisma deploy against the AWS environment
# ===========================================================================
aws-prisma-deploy: aws-env-banner
@export $$(cat aws.$(APPLICATION_NAME) | grep -v "#" | xargs) && \
export $$(cat aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | grep -v "#" | xargs) && \
export PRISMA_MANAGEMENT_API_SECRET="$(AWS_PRISMA_MANAGEMENT_API_SECRET)" && \
export PRISMA_SECRET="$(AWS_PRISMA_SERVICE_API_SECRET)" && \
export PRISMA_ENDPOINT="https://prisma.$${ApplicationDomainNamespace}" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Deploying Prisma datamodel to ${AWS_PRISMA_ENDPOINT}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)\n" && \
cd prisma && yarn deploy
# ===========================================================================
# Runs Prisma seed against the AWS environment
# ===========================================================================
aws-prisma-reseed: aws-env-banner
@export $$(cat aws.$(APPLICATION_NAME) | grep -v "#" | xargs) && \
export $$(cat aws.$(APPLICATION_NAME).$(ENVIRONMENT_NAME) | grep -v "#" | xargs) && \
export PRISMA_MANAGEMENT_API_SECRET="$(AWS_PRISMA_MANAGEMENT_API_SECRET)" && \
export PRISMA_SECRET="$(AWS_PRISMA_SERVICE_API_SECRET)" && \
printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Seeding ${PRISMA_ENDPOINT}" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)\n" && \
cd prisma && yarn reseed
# =================================================================
# Force an update of the Prisma service in AWS
# =================================================================
AWS_PRISMA_SERVICE_ARN_EXPORT := $(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-PrismaServiceArn
AWS_PRISMA_SERVICE_ARN := $$(aws cloudformation list-exports --query 'Exports[?Name==`$(AWS_PRISMA_SERVICE_ARN_EXPORT)`].Value' --output text)
aws-prisma-update-service: aws-env-banner
@echo PRISMA_SERVICE_ARN: ${AWS_PRISMA_SERVICE_ARN} && \
export PRISMA_SERVICE_ARN=$(AWS_PRISMA_SERVICE_ARN) && \
echo PRISMA_SERVICE_ARN: $${PRISMA_SERVICE_ARN} && \
aws ecs update-service --cluster $(APPLICATION_NAME)-$(ENVIRONMENT_NAME) --service "$${AWS_PRISMA_SERVICE_ARN}" --force-new-deployment
# =================================================================
# Force an update of the Apollo service in AWS
# =================================================================
AWS_APOLLO_SERVICE_ARN_EXPORT := $(APPLICATION_NAME)-$(ENVIRONMENT_NAME)-ApolloServiceArn
AWS_APOLLO_SERVICE_ARN := $$(aws cloudformation list-exports --query 'Exports[?Name==`$(AWS_APOLLO_SERVICE_ARN_EXPORT)`].Value' --output text)
aws-apollo-update-service: aws-env-banner
@printf "$(OK_COLOR)" && \
printf "\n%s\n" "======================================================================================" && \
printf "%s\n" "= Updating the Apollo service" && \
printf "%s" "======================================================================================" && \
printf "$(NO_COLOR)" && \
export APOLLO_SERVICE_ARN=$(AWS_APOLLO_SERVICE_ARN) && \
aws ecs update-service --cluster $(APPLICATION_NAME)-$(ENVIRONMENT_NAME) --service "$${APOLLO_SERVICE_ARN}" --force-new-deployment