diff --git a/_variables.tf b/_variables.tf index b520533..015ba49 100644 --- a/_variables.tf +++ b/_variables.tf @@ -16,9 +16,13 @@ variable "hostname_create" { } variable "cloudfront_logging_bucket" { + type = string + default = null description = "Bucket to store logs from app" } variable "cloudfront_logging_prefix" { + type = string + default = "" description = "Logging prefix" } \ No newline at end of file diff --git a/cloudfront.tf b/cloudfront.tf index c98a396..ce4c9c7 100644 --- a/cloudfront.tf +++ b/cloudfront.tf @@ -19,10 +19,14 @@ resource "aws_cloudfront_distribution" "default" { } } - logging_config { - include_cookies = false - bucket = "${var.cloudfront_logging_bucket}" - prefix = "${var.cloudfront_logging_prefix}" + dynamic "logging_config" { + for_each = "${compact([var.cloudfront_logging_bucket])}" + + content { + include_cookies = false + bucket = "${var.cloudfront_logging_bucket}" + prefix = "${var.cloudfront_logging_prefix}" + } } default_cache_behavior {