Skip to content

Commit

Permalink
Added support for blacklisting paths for caching
Browse files Browse the repository at this point in the history
This is related to #62
  • Loading branch information
dmattia committed Jan 9, 2020
1 parent a05cffd commit 73c7231
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,32 @@ resource "aws_cloudfront_distribution" "default" {
}
}

dynamic "ordered_cache_behavior" {
for_each = var.caching_blacklist
content {
path_pattern = ordered_cache_behavior.value
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
target_origin_id = module.distribution_label.id
compress = var.compress
trusted_signers = var.trusted_signers

forwarded_values {
query_string = var.forward_query_string
headers = var.forward_header_values

cookies {
forward = var.forward_cookies
}
}

viewer_protocol_policy = var.viewer_protocol_policy
default_ttl = 0
min_ttl = 0
max_ttl = 0
}
}

restrictions {
geo_restriction {
restriction_type = var.geo_restriction_type
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ variable "viewer_protocol_policy" {
default = "redirect-to-https"
}

variable "caching_blacklist" {
type = set(string)
default = []
description = "Paths of objects that should never be cached for any HTTP methods"
}

variable "allowed_methods" {
type = list(string)
default = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
Expand Down

0 comments on commit 73c7231

Please sign in to comment.