mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
Merge pull request #886 from Hestia-Homes/deploy-fastapi-with-terraform
Deploy fastapi with terraform: set caching behaviour based on request origin - api v s3
This commit is contained in:
commit
84dbe5bf93
1 changed files with 35 additions and 12 deletions
|
|
@ -46,23 +46,47 @@ resource "aws_cloudfront_distribution" "this" {
|
||||||
aliases = var.aliases
|
aliases = var.aliases
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# Default Cache Behavior
|
# Default Cache Behavior (S3)
|
||||||
##########################################
|
##########################################
|
||||||
|
|
||||||
default_cache_behavior {
|
default_cache_behavior {
|
||||||
target_origin_id = var.origins[0].origin_id
|
target_origin_id = "s3-origin"
|
||||||
|
|
||||||
|
viewer_protocol_policy = "redirect-to-https"
|
||||||
|
|
||||||
|
allowed_methods = ["GET", "HEAD"]
|
||||||
|
cached_methods = ["GET", "HEAD"]
|
||||||
|
|
||||||
|
forwarded_values {
|
||||||
|
query_string = false
|
||||||
|
|
||||||
|
cookies {
|
||||||
|
forward = "none"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compress = true
|
||||||
|
min_ttl = 0
|
||||||
|
default_ttl = 3600
|
||||||
|
max_ttl = 86400
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
# API Behavior
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
ordered_cache_behavior {
|
||||||
|
path_pattern = "/v1/*"
|
||||||
|
target_origin_id = "api-origin"
|
||||||
|
|
||||||
viewer_protocol_policy = "redirect-to-https"
|
viewer_protocol_policy = "redirect-to-https"
|
||||||
|
|
||||||
allowed_methods = [
|
allowed_methods = [
|
||||||
"GET",
|
"GET","HEAD","OPTIONS",
|
||||||
"HEAD"
|
"PUT","POST","PATCH","DELETE"
|
||||||
]
|
]
|
||||||
|
|
||||||
cached_methods = [
|
cached_methods = ["GET","HEAD"]
|
||||||
"GET",
|
|
||||||
"HEAD"
|
|
||||||
]
|
|
||||||
|
|
||||||
forwarded_values {
|
forwarded_values {
|
||||||
query_string = true
|
query_string = true
|
||||||
|
|
@ -73,10 +97,9 @@ resource "aws_cloudfront_distribution" "this" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compress = true
|
min_ttl = 0
|
||||||
min_ttl = 0
|
default_ttl = 0
|
||||||
default_ttl = 3600
|
max_ttl = 0
|
||||||
max_ttl = 86400
|
|
||||||
}
|
}
|
||||||
|
|
||||||
price_class = "PriceClass_All"
|
price_class = "PriceClass_All"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue