Merge pull request #887 from Hestia-Homes/main
Some checks are pending
Fast Api Backend Deploy / deploy (push) Waiting to run
Deploy infrastructure / determine_stage (push) Waiting to run
Deploy infrastructure / shared_terraform (push) Blocked by required conditions
Deploy infrastructure / ara_engine_image (push) Blocked by required conditions
Deploy infrastructure / ara_engine_lambda (push) Blocked by required conditions
Deploy infrastructure / address2uprn_image (push) Blocked by required conditions
Deploy infrastructure / address2uprn_lambda (push) Blocked by required conditions
Deploy infrastructure / postcodeSplitter_image (push) Blocked by required conditions
Deploy infrastructure / postcodeSplitter_lambda (push) Blocked by required conditions
Deploy infrastructure / condition_etl_image (push) Blocked by required conditions
Deploy infrastructure / condition_etl_lambda (push) Blocked by required conditions
Deploy infrastructure / categorisation_image (push) Blocked by required conditions
Deploy infrastructure / categorisation_lambda (push) Blocked by required conditions
Deploy infrastructure / ordnanceSurvey_image (push) Blocked by required conditions
Deploy infrastructure / ordnanceSurvey_lambda (push) Blocked by required conditions
Deploy infrastructure / fast_api_lambda (push) Blocked by required conditions
Deploy infrastructure / cloudfront_cdn (push) Blocked by required conditions

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:56:33 +00:00 committed by GitHub
commit 828e16e3f6
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"