Skip to content

Commit 60355d4

Browse files
jindrajVrtak-CZ
authored andcommitted
feat(cloudfront-logging): enable cloudfront_distribution logging to s3
1 parent 658800e commit 60355d4

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ module "static-site" {
128128
| <a name="input_gitlab_environment"></a> [gitlab\_environment](#input\_gitlab\_environment) | n/a | `string` | `"*"` | no |
129129
| <a name="input_gitlab_project_id"></a> [gitlab\_project\_id](#input\_gitlab\_project\_id) | n/a | `string` | `null` | no |
130130
| <a name="input_logs_bucket"></a> [logs\_bucket](#input\_logs\_bucket) | n/a | `string` | `null` | no |
131+
| <a name="input_logs_bucket_domain_name"></a> [logs\_bucket\_domain\_name](#input\_logs\_bucket\_domain\_name) | n/a | `string` | `null` | no |
131132
| <a name="input_override_status_code_403"></a> [override\_status\_code\_403](#input\_override\_status\_code\_403) | n/a | `number` | `403` | no |
132133
| <a name="input_override_status_code_404"></a> [override\_status\_code\_404](#input\_override\_status\_code\_404) | n/a | `number` | `200` | no |
133134
| <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 |

main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ resource "aws_cloudfront_distribution" "this" {
186186
minimum_protocol_version = "TLSv1.2_2018"
187187
}
188188

189+
dynamic "logging_config" {
190+
for_each = var.logs_bucket_domain_name == null ? [] : [1]
191+
192+
content {
193+
bucket = var.logs_bucket_domain_name
194+
prefix = "cloudfront/access_logs/${local.main_domain_sanitized}/"
195+
include_cookies = false
196+
}
197+
}
198+
189199
tags = local.tags
190200
}
191201

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ variable "logs_bucket" {
3131
default = null
3232
}
3333

34+
variable "logs_bucket_domain_name" {
35+
type = string
36+
default = null
37+
}
38+
3439
variable "cloudfront_price_class" {
3540
type = string
3641
default = "PriceClass_100"

0 commit comments

Comments
 (0)