Skip to content

Commit

Permalink
feat: enable of logging_config
Browse files Browse the repository at this point in the history
  • Loading branch information
Aatishsharma77 committed Apr 10, 2024
1 parent 436b31d commit 4eb40f7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/bucket-secure/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ module "cdn" {
trusted_signers = ["self"]
public_key_enable = true
public_key = "./cdn.pem"
access_log_bucket = module.s3_bucket.id

}


12 changes: 12 additions & 0 deletions examples/domain-cdn/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ locals {
environment = "test"
}

module "s3_bucket" {
source = "clouddrove/s3/aws"
version = "2.0.0"

name = "${local.name}-secure-bucket-cdn"
environment = local.environment
versioning = true
acl = "private"
}


module "acm" {
source = "clouddrove/acm/aws"
version = "1.4.1"
Expand All @@ -33,6 +44,7 @@ module "cdn" {
viewer_protocol_policy = "redirect-to-https"
allowed_methods = ["GET", "HEAD"]
acm_certificate_arn = module.acm.arn
access_log_bucket = module.s3_bucket.id
}


13 changes: 13 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ resource "aws_cloudfront_distribution" "bucket" {
max_ttl = var.max_ttl
}

logging_config {
include_cookies = var.include_cookies
bucket = var.access_log_bucket
prefix = var.prefix
}

restrictions {
geo_restriction {
restriction_type = var.geo_restriction_type
Expand Down Expand Up @@ -127,6 +133,13 @@ resource "aws_cloudfront_distribution" "domain" {
}
}

logging_config {
include_cookies = var.include_cookies
bucket = var.access_log_bucket
prefix = var.prefix
}


viewer_certificate {
cloudfront_default_certificate = var.acm_certificate_arn == "" ? true : false
acm_certificate_arn = var.acm_certificate_arn
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -304,4 +304,22 @@ variable "error_caching_min_ttl" {
type = string
default = "10"
description = "the value of errro caching min ttl"
}

variable "include_cookies" {
type = bool
default = null
description = "Whether to include cookies in access logs (default: false)."
}

variable "prefix" {
type = string
default = ""
description = "Prefix to the access log filenames for this distribution, for example, myprefix/"
}

variable "access_log_bucket" {
type = string
default = ""
description = "Amazon S3 bucket to store the access logs in, for example, myawslogbucket.s3.amazonaws.com."
}

0 comments on commit 4eb40f7

Please sign in to comment.