Skip to content

Commit a1e036e

Browse files
committed
update cfn
1 parent ddc7c0d commit a1e036e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,26 @@ local:
6464
VITE_BUILD_HASH=$(GIT_HASH) yarn run dev
6565

6666
deploy_prod: check_account_prod build
67+
@echo "Deploying CloudFormation stack..."
6768
sam deploy $(common_params) --parameter-overrides $(run_env)=prod $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)" S3BucketPrefix="$(s3_bucket_prefix)"
69+
@echo "Syncing S3 bucket..."
6870
aws s3 sync $(dist_ui_directory_root) s3://$(ui_s3_bucket)/ --delete
71+
make invalidate_cloudfront
6972

7073
deploy_dev: check_account_dev build
74+
@echo "Deploying CloudFormation stack..."
7175
sam deploy $(common_params) --parameter-overrides $(run_env)=dev $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)" S3BucketPrefix="$(s3_bucket_prefix)"
76+
@echo "Syncing S3 bucket..."
7277
aws s3 sync $(dist_ui_directory_root) s3://$(ui_s3_bucket)/ --delete
78+
make invalidate_cloudfront
79+
80+
invalidate_cloudfront:
81+
@echo "Creating CloudFront invalidation..."
82+
$(eval DISTRIBUTION_ID := $(shell aws cloudformation describe-stacks --stack-name $(application_key) --query "Stacks[0].Outputs[?OutputKey=='CloudfrontDistributionId'].OutputValue" --output text))
83+
$(eval INVALIDATION_ID := $(shell aws cloudfront create-invalidation --distribution-id $(DISTRIBUTION_ID) --paths "/*" --query 'Invalidation.Id' --output text --no-cli-page))
84+
@echo "Waiting on job $(INVALIDATION_ID)..."
85+
aws cloudfront wait invalidation-completed --distribution-id $(DISTRIBUTION_ID) --id $(INVALIDATION_ID)
86+
@echo "CloudFront invalidation completed!"
7387

7488
install:
7589
yarn -D

cloudformation/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,11 +571,7 @@ Resources:
571571
QueryString: false
572572
Cookies:
573573
Forward: none
574-
CachePolicyId: !If [
575-
IsProd,
576-
"658327ea-f89d-4fab-a63d-7e88639e58f6", # Caching-optimized in prod
577-
"4135ea2d-6df8-44a3-9df3-4b5a84be39ad", # caching disabled in dev
578-
]
574+
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # caching-optimized
579575
CacheBehaviors:
580576
- PathPattern: "/api/*"
581577
TargetOriginId: ApiGatewayOrigin

0 commit comments

Comments
 (0)