From 9bd2b93350e79cfa8c61891b5d93bcfee40b45bd Mon Sep 17 00:00:00 2001 From: Sukh <6563909+sukhpalp@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:40:25 -0700 Subject: [PATCH] Create a cache behavior for statistics (#2028) --- terraform/cloudfront.tf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/terraform/cloudfront.tf b/terraform/cloudfront.tf index e1b79353e5..21c591bbb2 100644 --- a/terraform/cloudfront.tf +++ b/terraform/cloudfront.tf @@ -347,6 +347,18 @@ resource "aws_cloudfront_distribution" "wfnews_geofencing_nginx" { response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_control_response_headers.id } + ordered_cache_behavior { + path_pattern = "/statistics" + allowed_methods = ["GET", "OPTIONS", "HEAD"] + cached_methods = ["GET", "HEAD"] + target_origin_id = "wfnews_nginx_${var.target_env}" + compress = true + viewer_protocol_policy = "redirect-to-https" + cache_policy_id = "658327ea-f89d-4fab-a63d-7e88639e58f6" + + response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_control_response_headers.id + } + ordered_cache_behavior { path_pattern = "/static/*" allowed_methods = ["GET", "HEAD"] @@ -572,6 +584,18 @@ resource "aws_cloudfront_distribution" "wfnews_geofencing_gov_api" { cache_policy_id = "658327ea-f89d-4fab-a63d-7e88639e58f6" } + ordered_cache_behavior { + path_pattern = "/statistics" + allowed_methods = ["GET", "OPTIONS", "HEAD"] + cached_methods = ["GET", "HEAD"] + target_origin_id = "wfnews_nginx_gov_${var.target_env}" + compress = true + viewer_protocol_policy = "redirect-to-https" + cache_policy_id = "658327ea-f89d-4fab-a63d-7e88639e58f6" + + response_headers_policy_id = aws_cloudfront_response_headers_policy.cache_control_response_headers.id + } + ordered_cache_behavior { path_pattern = "/static/*" allowed_methods = ["GET", "HEAD"]