Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 38 additions & 17 deletions deploy/infrastructure/prod/us-east-2/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,15 @@ resource "aws_cloudfront_distribution" "cdn" {

ordered_cache_behavior {
path_pattern = "/routing/v1/*"
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD", "OPTIONS"]
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD", "OPTIONS"]
target_origin_id = local.primary_origin_id
forwarded_values {
query_string = true
query_string_cache_keys = [
# See: https://specs.ipfs.tech/routing/http-routing-v1/#content-routing-api
"filter-addrs",
"filter-protocols",
]
cookies {
forward = "none"
}
}
cache_policy_id = aws_cloudfront_cache_policy.delegated_routing.id

compress = true
viewer_protocol_policy = "redirect-to-https"
min_ttl = 1200
default_ttl = 7200
max_ttl = 86400
}

ordered_cache_behavior {
path_pattern = "/ipni/v0/sample/*"
allowed_methods = ["GET", "HEAD", "OPTIONS"]
Expand Down Expand Up @@ -357,6 +345,39 @@ resource "aws_cloudfront_cache_policy" "lookup" {
}
}

resource "aws_cloudfront_cache_policy" "delegated_routing" {
name = "delegated_routing"

min_ttl = 1200
default_ttl = 7200
max_ttl = 86400

parameters_in_cache_key_and_forwarded_to_origin {
cookies_config {
cookie_behavior = "none"
}
headers_config {
header_behavior = "whitelist"
headers {
items = ["Accept"]
}
}
query_strings_config {
query_string_behavior = "whitelist"
query_strings {
items = [
# See: https://specs.ipfs.tech/routing/http-routing-v1/#content-routing-api
"filter-addrs",
"filter-protocols",
]
}
}

enable_accept_encoding_brotli = true
enable_accept_encoding_gzip = true
}
}

provider "aws" {
alias = "use1"
region = "us-east-1"
Expand Down
Loading