Skip to content

Commit

Permalink
feat(cloudfront-logging): enable cloudfront_distribution logging to s3
Browse files Browse the repository at this point in the history
  • Loading branch information
jindraj authored and Vrtak-CZ committed Jan 17, 2024
1 parent 658800e commit 60355d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ module "static-site" {
| <a name="input_gitlab_environment"></a> [gitlab\_environment](#input\_gitlab\_environment) | n/a | `string` | `"*"` | no |
| <a name="input_gitlab_project_id"></a> [gitlab\_project\_id](#input\_gitlab\_project\_id) | n/a | `string` | `null` | no |
| <a name="input_logs_bucket"></a> [logs\_bucket](#input\_logs\_bucket) | n/a | `string` | `null` | no |
| <a name="input_logs_bucket_domain_name"></a> [logs\_bucket\_domain\_name](#input\_logs\_bucket\_domain\_name) | n/a | `string` | `null` | no |
| <a name="input_override_status_code_403"></a> [override\_status\_code\_403](#input\_override\_status\_code\_403) | n/a | `number` | `403` | no |
| <a name="input_override_status_code_404"></a> [override\_status\_code\_404](#input\_override\_status\_code\_404) | n/a | `number` | `200` | no |
| <a name="input_proxy_paths"></a> [proxy\_paths](#input\_proxy\_paths) | n/a | <pre>list(object({<br> origin_domain = string<br> path_prefix = string<br> }))</pre> | `[]` | no |
Expand Down
10 changes: 10 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ resource "aws_cloudfront_distribution" "this" {
minimum_protocol_version = "TLSv1.2_2018"
}

dynamic "logging_config" {
for_each = var.logs_bucket_domain_name == null ? [] : [1]

content {
bucket = var.logs_bucket_domain_name
prefix = "cloudfront/access_logs/${local.main_domain_sanitized}/"
include_cookies = false
}
}

tags = local.tags
}

Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ variable "logs_bucket" {
default = null
}

variable "logs_bucket_domain_name" {
type = string
default = null
}

variable "cloudfront_price_class" {
type = string
default = "PriceClass_100"
Expand Down

0 comments on commit 60355d4

Please sign in to comment.