From 6e538e6f687392b162fb1ad5747cc0a7044b9f05 Mon Sep 17 00:00:00 2001 From: Cullan Carey Date: Wed, 11 May 2022 18:35:05 -0500 Subject: [PATCH] updated cloudfront to use Managed cache optimized policy --- .gitignore | 1 + cloudfront.tf | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index a066aa2..52adb69 100755 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Local .terraform directories **/.terraform/* +*.terraform* # .tfstate files *.tfstate diff --git a/cloudfront.tf b/cloudfront.tf index 7e4948e..3bb0802 100755 --- a/cloudfront.tf +++ b/cloudfront.tf @@ -70,21 +70,8 @@ resource "aws_cloudfront_distribution" "website_distribution" { allowed_methods = ["GET", "HEAD"] cached_methods = ["GET", "HEAD"] target_origin_id = "HA-website" - min_ttl = 0 - default_ttl = 0 - max_ttl = 0 + cache_policy_id = data.aws_cloudfront_cache_policy.cache_policy.id smooth_streaming = false - forwarded_values { - headers = [] - query_string = false - query_string_cache_keys = [] - - cookies { - forward = "none" - whitelisted_names = [] - } - } - } restrictions { geo_restriction { @@ -98,4 +85,10 @@ resource "aws_cloudfront_distribution" "website_distribution" { cloudfront_default_certificate = false minimum_protocol_version = "TLSv1.2_2021" } -} \ No newline at end of file +} + + +data "aws_cloudfront_cache_policy" "cache_policy" { + name = "Managed-CachingOptimized" +} +