Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds default gzip and brotli compression, variables to allow disabling #6

Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ locals {
}, var.cloudfront.hsts)
waf_logging_configuration = var.cloudfront.waf_logging_configuration
cache_policy = {
default_ttl = coalesce(try(var.cloudfront.cache_policy.default_ttl, null), 0)
min_ttl = coalesce(try(var.cloudfront.cache_policy.min_ttl, null), 0)
max_ttl = coalesce(try(var.cloudfront.cache_policy.max_ttl, null), 31536000)
default_ttl = coalesce(try(var.cloudfront.cache_policy.default_ttl, null), 0)
min_ttl = coalesce(try(var.cloudfront.cache_policy.min_ttl, null), 0)
max_ttl = coalesce(try(var.cloudfront.cache_policy.max_ttl, null), 31536000)
enable_accept_encoding_brotli = try(var.cloudfront.cache_policy.enable_accept_encoding_brotli, true)
enable_accept_encoding_gzip = try(var.cloudfront.cache_policy.enable_accept_encoding_gzip, true)
cookies_config = merge({
cookie_behavior = "all"
}, try(var.cloudfront.cache_policy.cookies_config, {}))
Expand Down
4 changes: 3 additions & 1 deletion modules/opennext-cloudfront/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ resource "aws_cloudfront_cache_policy" "cache_policy" {
min_ttl = var.cache_policy.min_ttl
max_ttl = var.cache_policy.max_ttl


parameters_in_cache_key_and_forwarded_to_origin {
enable_accept_encoding_brotli = var.cache_policy.enable_accept_encoding_brotli
enable_accept_encoding_gzip = var.cache_policy.enable_accept_encoding_gzip

cookies_config {
cookie_behavior = var.cache_policy.cookies_config.cookie_behavior

Expand Down
8 changes: 5 additions & 3 deletions modules/opennext-cloudfront/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,11 @@ variable "origin_request_policy" {

variable "cache_policy" {
type = object({
default_ttl = number
min_ttl = number
max_ttl = number
default_ttl = number
min_ttl = number
max_ttl = number
enable_accept_encoding_gzip = bool
enable_accept_encoding_brotli = bool
cookies_config = object({
cookie_behavior = string
items = optional(list(string))
Expand Down
8 changes: 5 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ variable "cloudfront" {
})))
}))
cache_policy = optional(object({
default_ttl = optional(number)
min_ttl = optional(number)
max_ttl = optional(number)
default_ttl = optional(number)
min_ttl = optional(number)
max_ttl = optional(number)
enable_accept_encoding_gzip = optional(bool)
enable_accept_encoding_brotli = optional(bool)
cookies_config = optional(object({
cookie_behavior = string
}))
Expand Down