-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathconfig.yml
1012 lines (969 loc) · 31.4 KB
/
config.yml
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
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
version: 2.1
orbs:
git-shallow-clone: guitarrapc/git-shallow-clone@2.6.0
efcms-docker-image: &efcms-docker-image $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/ef-cms-us-east-1:3.0.15
parameters:
run_build_and_deploy:
default: true
type: boolean
run_build_and_deploy_with_context:
default: true
type: boolean
run_glue_to_test:
default: false
type: boolean
run_glue_to_lower_env:
default: false
type: boolean
lower_env:
default: test
type: string
run_sync_s3_to_lower_env:
default: false
type: boolean
referrer:
default: ''
type: string
source_bucket:
default: ''
type: string
destination_bucket:
default: ''
type: string
commands:
npm-and-cypress-install:
steps:
- restore_cache:
keys:
- v27-npm-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- restore_cache:
keys:
- v27-cypress-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- run:
name: Install node dependencies
command: |
if [ ! -d node_modules ]; then
npm ci
else
echo package.json and package-lock.json are unchanged. Using cached node_modules folder.
fi
- run:
name: Install Cypress dependency
command: |
if [ ! -d ~/.cache/Cypress ]; then
echo Installing Cypress
./node_modules/.bin/cypress install
else
echo Found cached Cypress version. Using cached Cypress folder.
fi
- run:
name: Reset package-lock
command: 'git checkout -- package-lock.json'
- save_cache:
key: v27-npm-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
paths:
- node_modules
- save_cache:
key: v27-cypress-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
paths:
- ~/.cache/Cypress
npm-install:
steps:
- restore_cache:
keys:
- v27-npm-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
- run:
name: Install node dependencies
command: |
if [ ! -d node_modules ]; then
npm ci
else
echo package.json and package-lock.json are unchanged. Using cached node_modules folder.
fi
- run:
name: Reset package-lock
command: 'git checkout -- package-lock.json'
- save_cache:
key: v27-npm-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
paths:
- node_modules
jobs:
deploy:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Build Docker Image
command: |
cd web-api/runtimes/puppeteer && ./build.sh && cd ../../..
- run:
name: Setup Blue Green Migration If Needed
command: |
./setup-for-blue-green-migration.sh
- run:
name: Setup Migrate Flag
command: echo "export MIGRATE_FLAG=$(./scripts/dynamo/get-migrate-flag.sh $ENV)" >> $BASH_ENV
- run:
name: Setup Destination Table Var
command: echo "export DESTINATION_TABLE=$(./scripts/dynamo/get-destination-table.sh $ENV)" >> $BASH_ENV
- run:
no_output_timeout: 20m
name: 'Deploy - Web API - Terraform'
command: |
cd web-api/terraform/main && ../bin/deploy-app.sh $ENV
- run:
no_output_timeout: 20m
name: 'Deploy - Web Client - Terraform'
command: |
cd web-client/terraform/main && ../bin/deploy-app.sh $ENV
- run:
name: Setup Elasticsearch Index Settings
command: |
./web-api/setup-elasticsearch-index.sh $ENV
- run:
name: Admin User Setup
command: |
if [ "${CIRCLE_BRANCH}" != "prod" ]; then
npx ts-node --transpile-only shared/admin-tools/user/setup-admin.ts
else
echo "skipping…"
fi
- run:
name: Test Users Setup
command: |
if [ "${CIRCLE_BRANCH}" != "prod" ]; then
./shared/admin-tools/user/setup-test-users.sh $ENV
else
echo "skipping…"
fi
- run:
name: Setup Judge Users File Var
command: |
if [ "${CIRCLE_BRANCH}" != "prod" ] && [ "${CIRCLE_BRANCH}" != "test" ] && [ "${CIRCLE_BRANCH}" != "migration" ]; then
echo "export FILE_NAME=./scripts/data-import/judge/judge_users.csv" >> $BASH_ENV
else
echo "skipping…"
fi
- run:
name: Judge Users Setup
command: |
if [ "${CIRCLE_BRANCH}" != "prod" ] && [ "${CIRCLE_BRANCH}" != "test" ] && [ "${CIRCLE_BRANCH}" != "migration" ]; then
./scripts/data-import/judge/bulk-import-judge-users.sh
else
echo "skipping…"
fi
- run:
name: 'Deploy - Web Client - S3'
command: |
./web-client/deploy-ui.sh
- run:
name: 'Deploy - Public Web Client - S3'
command: |
./web-client/deploy-public.sh
- run:
name: 'Deploy - Web API - Cognito Customize'
command: |
cd web-api && ./setup-cognito-ui.sh $ENV
- run:
name: 'Deploy - Authorizer Smoke Tests'
command: |
npm run verify-authorizers -- $ENV
- run:
name: 'Deploy - Verify Private S3 Buckets'
command: |
npm run verify-private-s3-buckets -- $ENV
- run:
name: 'Deploy - Verify Private Elasticsearch'
command: |
npm run verify-private-elasticsearch -- $ENV
- run:
name: 'Deploy - Verify Cognito Lambda Triggers'
command: |
npm run verify-cognito-lambda-triggers -- $ENV
- run:
name: 'Deploy - Verify USTC Admin User Disabled'
command: |
if [ "${CIRCLE_BRANCH}" != "prod" ]; then
npx ts-node --transpile-only shared/admin-tools/user/verify-ustc-admin-user-disabled.js
else
echo "Skipping verify admin user disabled step on prod"
fi
- store_artifacts:
path: /home/app/cypress-smoketests/videos/
- run:
name: 'Deploy - Pending Color Switch'
command: npm run pending-color-switch
migrate:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Deploy Check Migration Status Cron Lambda
command: |
npm run deploy:migration-cron -- $ENV
- run:
name: Setup Migration Infrastructure
command: |
if [ "$MIGRATE_FLAG" == "true" ]; then
npm run deploy:migration -- $ENV
fi
- run:
name: Disable Destination Table Stream
command: |
if [ "$MIGRATE_FLAG" == "true" ]; then
./web-api/disable-deploying-dynamo-stream-trigger.sh
fi
- run:
name: Run Migration
command: |
if [ "$MIGRATE_FLAG" == "true" ]; then
npm run start:migration -- $ENV
fi
- run:
name: Enable Check Migration Status Cron
command: |
./web-api/workflow-terraform/migration-cron/bin/enable.sh
prepare-for-reindex:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Disable Check Migration Status Cron
command: |
./web-api/workflow-terraform/migration-cron/bin/disable.sh
- run:
name: Deploy Check Reindex Status Cron Lambda
command: |
npm run deploy:reindex-cron -- $ENV
- run:
name: Track successful migrations
command: |
if [ "$MIGRATE_FLAG" == "true" ]; then
node ./web-api/track-successful-migrations.js
fi
- run:
name: Enable Destination Table Stream
command: |
if [ "$MIGRATE_FLAG" == "true" ]; then
./web-api/enable-deploying-dynamo-stream-trigger.sh
fi
- run:
name: Enable Check Reindex Status Cron
command: |
./web-api/workflow-terraform/reindex-cron/bin/enable.sh
disable-reindex-cron:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Disable Check Reindex Status Cron
command: |
./web-api/workflow-terraform/reindex-cron/bin/disable.sh
smoketests:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-and-cypress-install
- run:
name: Create Cypress Artifacts Directory
command: mkdir /tmp/cypress
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: 'Disable Maintenance Mode'
command: npm run maintenance:disengage $ENV
- run:
name: 'Cypress Smoke Tests'
command: npm run cypress:smoketests
- run:
name: 'Pa11y Smoke Tests'
command: npm run test:pa11y:smoketests
- store_artifacts:
path: /root/project/cypress/cypress-smoketests/videos/
smoketests-readonly:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-and-cypress-install
- run:
name: Create Cypress Artifacts Directory
command: mkdir /tmp/cypress
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Create and Enable Test User
command: npx ts-node --transpile-only ./scripts/create-and-enable-smoketest-user.js
- run:
name: 'Cypress Readonly Smoke Tests'
command: |
set +e
npm run cypress:readonly
echo "export READONLY_SMOKETESTS_RESULT=$?" >> $BASH_ENV
set -e
- run:
name: Disable Test User
command: npx ts-node --transpile-only ./scripts/disable-smoketest-user.js
- run:
name: Kill Build if Smoketests Failed
command: ./scripts/kill-circle-build.sh
- run:
name: 'Cypress Public Readonly Smoke Tests'
command: npm run cypress:readonly:public
- store_artifacts:
path: /root/project/cypress-readonly/videos/
loadtests:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-and-cypress-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: 'Load tests'
command: npm run loadtest:pdf-generation
deploy-switch-colors-cron:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
steps:
- git-shallow-clone/checkout
- npm-and-cypress-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Deploy Switch Colors Cron
command: |
npm run deploy:switch-colors-cron -- $ENV
disable-switch-colors-cron:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
steps:
- git-shallow-clone/checkout
- npm-and-cypress-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Disable Switch Colors Cron
command: |
npm run destroy:switch-colors-cron -- $ENV
switch-colors:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: 'Switch Colors'
command: npm run switch-colors
backup-source-dynamo-table:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: small
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Backup Source DynamoDB table
command: |
if [ $MIGRATE_FLAG == true ]; then
npm run backup:dynamo-table -- $SOURCE_TABLE
fi
delete-api-mappings:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: small
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Delete Source API Gateway Mappings
command: |
npm run delete:api-gateway-mappings -- "${EFCMS_DOMAIN}" "${DEPLOYING_COLOR}"
cleanup:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Destroy Migration Infrastructure
command: |
if [ $MIGRATE_FLAG == true ]; then
npm run destroy:migration -- $ENV
fi
- run:
name: Destroy Check Migration Status Cron Infrastructure
command: |
npm run destroy:migration-cron -- $ENV
- run:
name: Destroy Check Reindex Status Cron Infrastructure
command: |
npm run destroy:reindex-cron -- $ENV
- run:
name: Delete Source ElasticSearch cluster
command: |
if [ $MIGRATE_FLAG == true ]; then
npm run delete:elasticsearch-cluster -- $SOURCE_ELASTICSEARCH
fi
- run:
name: Delete Source Dynamo table
command: |
if [ $MIGRATE_FLAG == true ]; then
npm run delete:dynamo-table -- $SOURCE_TABLE
fi
- run:
name: Cleanup Deploy Table After Migration
command: |
if [ $MIGRATE_FLAG == true ]; then
npm run migration:cleanup -- $ENV
fi
######################## GLUE JOB: Jobs that run in a lower environment ########################
delete-existing-data:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Setup the deploy table for a glue job
command: |
./scripts/setup-deploy-table-for-glue-job.sh
- run:
name: Delete all existing dynamodb tables and elasticsearch clusters
command: |
./scripts/delete-all-persistence.sh
redeploy-environment:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
VCS=<< pipeline.project.type >>
CIRCLE_PROJECT_SLUG="${VCS}/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
echo "export CIRCLE_PROJECT_SLUG=${CIRCLE_PROJECT_SLUG}" >> $BASH_ENV
- run:
name: Kick off a deployment
command: |
CIRCLE_PIPELINE_ID=$(curl --request POST \
--url "https://circleci.com/api/v2/project/${CIRCLE_PROJECT_SLUG}/pipeline" \
--header "Circle-Token: ${CIRCLE_MACHINE_USER_TOKEN}" \
--header "content-type: application/json" \
--data "{\"branch\":\"${CIRCLE_BRANCH}\"}" | jq -r '.id')
echo "export CIRCLE_PIPELINE_ID=${CIRCLE_PIPELINE_ID}" >> $BASH_ENV
- run:
name: Deploy Wait for Workflow Cron Lambda
command: |
export APPROVAL_JOB_NAME=wait-for-deployment-workflow
npm run deploy:wait-for-workflow-cron -- $ENV
- run:
name: Enable Wait for Workflow Cron
command: |
./web-api/workflow-terraform/wait-for-workflow-cron/bin/enable.sh
initiate-glue-job:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
source $BASH_ENV
VCS=<< pipeline.project.type >>
CIRCLE_PROJECT_SLUG="${VCS}/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
echo "export CIRCLE_PROJECT_SLUG=${CIRCLE_PROJECT_SLUG}" >> $BASH_ENV
if [[ -z "$PROD_DOCUMENTS_BUCKET_NAME" ]]; then
echo "Error: expected PROD_DOCUMENTS_BUCKET_NAME environment variable"
exit 1
fi
echo "export SOURCE_BUCKET=${PROD_DOCUMENTS_BUCKET_NAME}" >> $BASH_ENV
echo "export DESTINATION_BUCKET=${EFCMS_DOMAIN}-documents-${ENV}-us-east-1" >> $BASH_ENV
- run:
name: Disable Wait for Workflow Cron
command: |
./web-api/workflow-terraform/wait-for-workflow-cron/bin/disable.sh
- run:
name: Destroy Wait for Workflow Lambda
command: |
export APPROVAL_JOB_NAME=wait-for-deployment-workflow
export CIRCLE_PIPELINE_ID=noop
npm run destroy:wait-for-workflow-cron -- $ENV
- run:
name: Disable Dynamodb Streams
command: |
./shared/admin-tools/dynamodb/toggle-streams.sh --off
- run:
name: Kick off the glue-to-lower-env workflow
command: |
CIRCLE_PIPELINE_ID=$(curl --request POST \
--url "https://circleci.com/api/v2/project/${CIRCLE_PROJECT_SLUG}/pipeline" \
--header "Circle-Token: ${CIRCLE_MACHINE_USER_TOKEN}" \
--header "content-type: application/json" \
--data "{\"branch\":\"prod\", \"parameters\":{ \
\"run_build_and_deploy_with_context\":false, \
\"run_glue_to_lower_env\":true, \
\"lower_env\":\"${ENV}\"}}" | jq -r '.id')
echo "export CIRCLE_PIPELINE_ID=${CIRCLE_PIPELINE_ID}" >> $BASH_ENV
- run:
name: Deploy Wait for Workflow Cron Lambda
command: |
export APPROVAL_JOB_NAME=wait-for-glue-workflow
npm run deploy:wait-for-workflow-cron -- $ENV
- run:
name: Enable Wait for Workflow Cron
command: |
./web-api/workflow-terraform/wait-for-workflow-cron/bin/enable.sh
- run:
name: Kick off the sync-s3-to-lower-env workflow
command: |
curl --request POST \
--url "https://circleci.com/api/v2/project/${CIRCLE_PROJECT_SLUG}/pipeline" \
--header "Circle-Token: ${CIRCLE_MACHINE_USER_TOKEN}" \
--header "content-type: application/json" \
--data "{\"branch\":\"${CIRCLE_BRANCH}\", \"parameters\":{ \
\"run_build_and_deploy\":false, \
\"run_sync_s3_to_lower_env\":true, \
\"referrer\":\"${CIRCLE_WORKFLOW_ID}\", \
\"source_bucket\":\"${SOURCE_BUCKET}\", \
\"destination_bucket\":\"${DESTINATION_BUCKET}\"}}"
cleanup-glue-job:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Disable Wait for Workflow Cron
command: |
./web-api/workflow-terraform/wait-for-workflow-cron/bin/disable.sh
- run:
name: Destroy Wait for Workflow Lambda
command: |
export APPROVAL_JOB_NAME=wait-for-glue-workflow
export CIRCLE_PIPELINE_ID=noop
npm run destroy:wait-for-workflow-cron -- $ENV
- run:
name: Enable Dynamodb Streams
command: |
./shared/admin-tools/dynamodb/toggle-streams.sh --on
sync-s3-buckets-with-timeout:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
VCS=<< pipeline.project.type >>
CIRCLE_PROJECT_SLUG="${VCS}/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
echo "export CIRCLE_PROJECT_SLUG=${CIRCLE_PROJECT_SLUG}" >> $BASH_ENV
REFERRER=<< pipeline.parameters.referrer >>
if [[ -z "$REFERRER" ]]; then
echo "Error: no referrer was provided"
exit 1
fi
SOURCE_BUCKET=<< pipeline.parameters.source_bucket >>
if [[ -z "$SOURCE_BUCKET" ]]; then
echo "Error: no source bucket was provided"
exit 1
fi
DESTINATION_BUCKET=<< pipeline.parameters.destination_bucket >>
if [[ -z "$DESTINATION_BUCKET" ]]; then
echo "Error: no destination bucket was provided"
exit 1
fi
echo "export REFERRER=${REFERRER}" >> $BASH_ENV
echo "export SOURCE_BUCKET=${SOURCE_BUCKET}" >> $BASH_ENV
echo "export DESTINATION_BUCKET=${DESTINATION_BUCKET}" >> $BASH_ENV
- run:
name: Sync S3 buckets with timeout
command: |
./scripts/sync-s3-buckets-with-timeout.sh 175m
######################## GLUE JOB: Jobs that run in prod ########################
start-glue-job:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
LOWER_ENV=<< pipeline.parameters.lower_env >>
if [[ -z "$LOWER_ENV" ]]; then
echo "Error: no lower environment was provided"
exit 1
fi
echo "export LOWER_ENV=${LOWER_ENV}" >> $BASH_ENV
- run:
name: Deploy Check Glue Job Run State Cron Lambda
command: |
npm run deploy:glue-cron -- $ENV
- run:
name: Start Glue Job
command: |
npx ts-node --transpile-only scripts/glue/start-glue-job.ts "efcms-${LOWER_ENV}-alpha"
- run:
name: Enable Check Glue Job Run State Cron
command: |
./web-api/workflow-terraform/glue-cron/bin/enable.sh
finish-glue-job:
docker:
- image: *efcms-docker-image
aws_auth:
aws_access_key_id: $AWS_ACCESS_KEY_ID
aws_secret_access_key: $AWS_SECRET_ACCESS_KEY
resource_class: medium+
steps:
- git-shallow-clone/checkout
- npm-install
- run:
name: Setup Env
command: |
./scripts/env/env-for-circle.sh
- run:
name: Disable Check Glue Job Run State Cron
command: |
./web-api/workflow-terraform/glue-cron/bin/disable.sh
- run:
name: Destroy Check Glue Job Run State Cron Lambda
command: |
npm run destroy:glue-cron -- $ENV
only-prod: &only-prod
context: efcms-<< pipeline.git.branch >>
filters:
branches:
only:
- prod
only-test: &only-test
filters:
branches:
only:
- test
only-deployed-lower-environments: &only-deployed-lower-environments
filters:
branches:
only:
- develop
- experimental1
- experimental2
- experimental3
- experimental4
- experimental5
- irs
- migration
- staging
- test
workflows:
version: 2
build-and-deploy:
when: << pipeline.parameters.run_build_and_deploy >>
jobs:
- deploy:
<<: *only-deployed-lower-environments
- migrate:
<<: *only-deployed-lower-environments
requires:
- deploy
- wait-for-migration:
<<: *only-deployed-lower-environments
type: approval
requires:
- migrate
- prepare-for-reindex:
<<: *only-deployed-lower-environments
requires:
- wait-for-migration
- wait-for-reindex:
<<: *only-deployed-lower-environments
type: approval
requires:
- prepare-for-reindex
- disable-reindex-cron:
<<: *only-deployed-lower-environments
requires:
- wait-for-reindex
- smoketests:
<<: *only-deployed-lower-environments
requires:
- disable-reindex-cron
- loadtests:
<<: *only-deployed-lower-environments
requires:
- smoketests
- smoketests-readonly:
<<: *only-deployed-lower-environments
requires:
- loadtests
- switch-colors:
<<: *only-deployed-lower-environments
requires:
- smoketests-readonly
- delete-api-mappings:
<<: *only-deployed-lower-environments
requires:
- switch-colors
- cleanup:
<<: *only-deployed-lower-environments
requires:
- switch-colors
build-and-deploy-with-context:
when: << pipeline.parameters.run_build_and_deploy_with_context >>
jobs:
- deploy:
<<: *only-prod
- migrate:
<<: *only-prod
requires:
- deploy
- wait-for-migration:
<<: *only-prod
type: approval
requires:
- migrate
- prepare-for-reindex:
<<: *only-prod
requires:
- wait-for-migration
- wait-for-reindex:
<<: *only-prod
type: approval
requires:
- prepare-for-reindex
- disable-reindex-cron:
<<: *only-prod
requires:
- wait-for-reindex
- loadtests:
<<: *only-prod
requires:
- disable-reindex-cron
- smoketests-readonly:
<<: *only-prod
requires:
- loadtests
- deploy-switch-colors-cron:
<<: *only-prod
requires:
- smoketests-readonly
- wait-for-switch:
<<: *only-prod
type: approval
requires:
- deploy-switch-colors-cron
- disable-switch-colors-cron:
<<: *only-prod
requires:
- wait-for-switch
- switch-colors:
<<: *only-prod
requires:
- disable-switch-colors-cron
- backup-source-dynamo-table:
<<: *only-prod
requires:
- switch-colors
- delete-api-mappings:
<<: *only-prod
requires:
- switch-colors
- cleanup:
<<: *only-prod
requires:
- backup-source-dynamo-table
- delete-api-mappings
glue-to-test:
when:
or:
- equal: [glue-to-test-schedule, << pipeline.schedule.name >>]
- << pipeline.parameters.run_glue_to_test >>
jobs:
- delete-existing-data:
<<: *only-test
- redeploy-environment:
<<: *only-test
requires:
- delete-existing-data
- wait-for-deployment-workflow:
<<: *only-test
type: approval
requires:
- redeploy-environment
- initiate-glue-job:
<<: *only-test
requires:
- wait-for-deployment-workflow
- wait-for-glue-workflow:
<<: *only-test
type: approval
requires:
- initiate-glue-job
- wait-for-s3-sync-workflow:
<<: *only-test
type: approval
requires:
- initiate-glue-job
- cleanup-glue-job:
<<: *only-test
requires:
- wait-for-glue-workflow
- wait-for-s3-sync-workflow
glue-to-lower-env:
when: << pipeline.parameters.run_glue_to_lower_env >>
jobs:
- start-glue-job:
<<: *only-prod
- wait-for-glue-job:
<<: *only-prod
type: approval