mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
use managed cloudfront caching and forwarding policies instead of defining our own
This commit is contained in:
parent
867cebc9f2
commit
c91193ed22
1 changed files with 6 additions and 40 deletions
|
|
@ -1,39 +1,9 @@
|
|||
resource "aws_cloudfront_cache_policy" "api" {
|
||||
name = "api-no-cache"
|
||||
|
||||
default_ttl = 0
|
||||
max_ttl = 0
|
||||
min_ttl = 0
|
||||
|
||||
parameters_in_cache_key_and_forwarded_to_origin {
|
||||
cookies_config {
|
||||
cookie_behavior = "none"
|
||||
}
|
||||
|
||||
headers_config {
|
||||
header_behavior = "none"
|
||||
}
|
||||
|
||||
query_strings_config {
|
||||
query_string_behavior = "none"
|
||||
}
|
||||
}
|
||||
data "aws_cloudfront_cache_policy" "caching_disabled" {
|
||||
name = "Managed-CachingDisabled"
|
||||
}
|
||||
|
||||
resource "aws_cloudfront_origin_request_policy" "api" {
|
||||
name = "api-forward-all"
|
||||
|
||||
headers_config {
|
||||
header_behavior = "allViewer"
|
||||
}
|
||||
|
||||
query_strings_config {
|
||||
query_string_behavior = "all"
|
||||
}
|
||||
|
||||
cookies_config {
|
||||
cookie_behavior = "all"
|
||||
}
|
||||
data "aws_cloudfront_origin_request_policy" "all_viewer_except_host_header" {
|
||||
name = "Managed-AllViewerExceptHostHeader"
|
||||
}
|
||||
|
||||
############################################
|
||||
|
|
@ -122,12 +92,8 @@ resource "aws_cloudfront_distribution" "this" {
|
|||
allowed_methods = ["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"]
|
||||
cached_methods = ["GET","HEAD"]
|
||||
|
||||
cache_policy_id = aws_cloudfront_cache_policy.api.id
|
||||
origin_request_policy_id = aws_cloudfront_origin_request_policy.api.id
|
||||
|
||||
min_ttl = 0
|
||||
default_ttl = 0
|
||||
max_ttl = 0
|
||||
cache_policy_id = data.aws_cloudfront_cache_policy.caching_disabled.id
|
||||
origin_request_policy_id = data.aws_cloudfront_origin_request_policy.all_viewer_except_host_header.id
|
||||
}
|
||||
|
||||
price_class = "PriceClass_All"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue