|
1 | | -run_env = ParameterKey=RunEnvironment,ParameterValue |
2 | | -set_application_prefix = ParameterKey=ApplicationPrefix,ParameterValue |
3 | | -set_application_name = ParameterKey=ApplicationFriendlyName,ParameterValue |
4 | | - |
5 | 1 | prod_aws_account = 298118738376 |
6 | 2 | dev_aws_account = 427040638965 |
7 | 3 | current_aws_account := $(shell aws sts get-caller-identity --query Account --output text) |
8 | 4 |
|
9 | 5 | src_directory_root = src/ |
10 | 6 | dist_ui_directory_root = dist_ui/ |
11 | 7 | integration_test_directory_root = tests/live_integration/ |
12 | | - |
13 | | -# CHANGE ME (as needed) |
14 | | -application_key=infra-core-api |
15 | | -application_name="InfraCoreApi" |
16 | | - |
17 | | -region="us-east-1" |
18 | | - |
19 | | -# DO NOT CHANGE |
20 | | -common_params = --no-confirm-changeset \ |
21 | | - --no-fail-on-empty-changeset \ |
22 | | - --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \ |
23 | | - --region $(region) \ |
24 | | - --stack-name $(application_key) \ |
25 | | - --tags "project=$(application_key)" "techlead=$(techlead)" \ |
26 | | - --s3-prefix $(application_key) \ |
27 | | - --resolve-s3 |
28 | | - |
29 | | -s3_bucket_prefix = "$(current_aws_account)-$(region)-$(application_key)" |
30 | | -ui_s3_bucket = "$(s3_bucket_prefix)-ui" |
31 | | -docs_s3_bucket = "$(s3_bucket_prefix)-docs" |
32 | | - |
33 | | - |
34 | 8 | GIT_HASH := $(shell git rev-parse --short HEAD) |
35 | | -ORIGIN_SECRET := $(shell openssl rand -hex 32) |
36 | 9 |
|
37 | 10 | .PHONY: clean |
38 | 11 |
|
@@ -81,40 +54,15 @@ build: src/ |
81 | 54 | local: |
82 | 55 | VITE_BUILD_HASH=$(GIT_HASH) yarn run dev |
83 | 56 |
|
84 | | - |
85 | | -postdeploy: |
86 | | - @echo "Syncing S3 UI bucket..." |
87 | | - aws s3 sync $(dist_ui_directory_root) s3://$(ui_s3_bucket)/ --delete |
88 | | - aws s3 sync $(dist_ui_directory_root) s3://$(s3_bucket_prefix)/ --delete |
89 | | - make invalidate_cloudfront |
90 | | - |
91 | 57 | deploy_prod: check_account_prod |
92 | | - @echo "Deploying CloudFormation stack..." |
93 | | - @sam deploy $(common_params) --parameter-overrides $(run_env)=prod $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)" S3BucketPrefix="$(s3_bucket_prefix)" CloudfrontOriginSecret="$(ORIGIN_SECRET)" |
94 | 58 | @echo "Deploying Terraform..." |
95 | | - $(eval MAIN_DISTRIBUTION_ID := $(shell aws cloudformation describe-stacks --stack-name $(application_key) --query "Stacks[0].Outputs[?OutputKey=='CloudfrontDistributionId'].OutputValue" --output text)) |
96 | 59 | terraform -chdir=terraform/envs/prod init -lockfile=readonly |
97 | | - terraform -chdir=terraform/envs/prod apply -auto-approve -var main_cloudfront_distribution_id="$(MAIN_DISTRIBUTION_ID)" |
98 | | - make postdeploy |
| 60 | + terraform -chdir=terraform/envs/prod apply -auto-approve |
99 | 61 |
|
100 | 62 | deploy_dev: check_account_dev |
101 | 63 | @echo "Deploying Terraform..." |
102 | 64 | terraform -chdir=terraform/envs/qa init -lockfile=readonly |
103 | 65 | terraform -chdir=terraform/envs/qa apply -auto-approve |
104 | | - make postdeploy |
105 | | - |
106 | | -invalidate_cloudfront: |
107 | | - @echo "Creating CloudFront invalidation..." |
108 | | - $(eval DISTRIBUTION_ID := $(shell aws cloudformation describe-stacks --stack-name $(application_key) --query "Stacks[0].Outputs[?OutputKey=='CloudfrontDistributionId'].OutputValue" --output text)) |
109 | | - $(eval DISTRIBUTION_ID_2 := $(shell aws cloudformation describe-stacks --stack-name $(application_key) --query "Stacks[0].Outputs[?OutputKey=='CloudfrontIcalDistributionId'].OutputValue" --output text)) |
110 | | - $(eval INVALIDATION_ID := $(shell aws cloudfront create-invalidation --distribution-id $(DISTRIBUTION_ID) --paths "/*" --query 'Invalidation.Id' --output text --no-cli-page)) |
111 | | - $(eval INVALIDATION_ID_2 := $(shell aws cloudfront create-invalidation --distribution-id $(DISTRIBUTION_ID_2) --paths "/*" --query 'Invalidation.Id' --output text --no-cli-page)) |
112 | | - @echo "Triggered invalidation jobs $(INVALIDATION_ID) and $(INVALIDATION_ID_2)..." |
113 | | - @echo "Waiting on job $(INVALIDATION_ID)..." |
114 | | - aws cloudfront wait invalidation-completed --distribution-id $(DISTRIBUTION_ID) --id $(INVALIDATION_ID) |
115 | | - @echo "Waiting on job $(INVALIDATION_ID_2)..." |
116 | | - aws cloudfront wait invalidation-completed --distribution-id $(DISTRIBUTION_ID_2) --id $(INVALIDATION_ID_2) |
117 | | - @echo "CloudFront invalidation completed!" |
118 | 66 |
|
119 | 67 | init_terraform: |
120 | 68 | terraform -chdir=terraform/envs/qa init |
|
0 commit comments