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:
Jun-te Kim 2026-03-16 12:25:50 +00:00 committed by GitHub
commit 84dbe5bf93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,23 +46,47 @@ resource "aws_cloudfront_distribution" "this" {
aliases = var.aliases
##########################################
# Default Cache Behavior
# Default Cache Behavior (S3)
##########################################
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"
allowed_methods = [
"GET",
"HEAD"
"GET","HEAD","OPTIONS",
"PUT","POST","PATCH","DELETE"
]
cached_methods = [
"GET",
"HEAD"
]
cached_methods = ["GET","HEAD"]
forwarded_values {
query_string = true
@ -73,10 +97,9 @@ resource "aws_cloudfront_distribution" "this" {
}
}
compress = true
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
min_ttl = 0
default_ttl = 0
max_ttl = 0
}
price_class = "PriceClass_All"