Skip to content

Commit 3167d65

Browse files
feat: ALB Connection logging (#334)
Co-authored-by: Bryant Biggs <[email protected]>
1 parent 7339d02 commit 3167d65

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ No modules.
385385
|------|-------------|------|---------|:--------:|
386386
| <a name="input_access_logs"></a> [access\_logs](#input\_access\_logs) | Map containing access logging configuration for load balancer | `map(string)` | `{}` | no |
387387
| <a name="input_associate_web_acl"></a> [associate\_web\_acl](#input\_associate\_web\_acl) | Indicates whether a Web Application Firewall (WAF) ACL should be associated with the load balancer | `bool` | `false` | no |
388+
| <a name="input_connection_logs"></a> [connection\_logs](#input\_connection\_logs) | Map containing access logging configuration for load balancer | `map(string)` | `{}` | no |
388389
| <a name="input_create"></a> [create](#input\_create) | Controls if resources should be created (affects nearly all resources) | `bool` | `true` | no |
389390
| <a name="input_create_security_group"></a> [create\_security\_group](#input\_create\_security\_group) | Determines if a security group is created | `bool` | `true` | no |
390391
| <a name="input_customer_owned_ipv4_pool"></a> [customer\_owned\_ipv4\_pool](#input\_customer\_owned\_ipv4\_pool) | The ID of the customer owned ipv4 pool to use for this load balancer | `string` | `null` | no |

examples/complete-alb/main.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ module "alb" {
5858

5959
access_logs = {
6060
bucket = module.log_bucket.s3_bucket_id
61+
prefix = "access-logs"
62+
}
63+
64+
connection_logs = {
65+
bucket = module.log_bucket.s3_bucket_id
66+
enabled = true
67+
prefix = "connection-logs"
6168
}
6269

6370
listeners = {

main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ resource "aws_lb" "this" {
2222
}
2323
}
2424

25+
dynamic "connection_logs" {
26+
for_each = length(var.connection_logs) > 0 ? [var.connection_logs] : []
27+
content {
28+
bucket = connection_logs.value.bucket
29+
enabled = try(connection_logs.value.enabled, true)
30+
prefix = try(connection_logs.value.prefix, null)
31+
}
32+
}
33+
2534
customer_owned_ipv4_pool = var.customer_owned_ipv4_pool
2635
desync_mitigation_mode = var.desync_mitigation_mode
2736
dns_record_client_routing_policy = var.dns_record_client_routing_policy

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ variable "access_logs" {
2020
default = {}
2121
}
2222

23+
variable "connection_logs" {
24+
description = "Map containing access logging configuration for load balancer"
25+
type = map(string)
26+
default = {}
27+
}
28+
2329
variable "customer_owned_ipv4_pool" {
2430
description = "The ID of the customer owned ipv4 pool to use for this load balancer"
2531
type = string

wrappers/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module "wrapper" {
55

66
access_logs = try(each.value.access_logs, var.defaults.access_logs, {})
77
associate_web_acl = try(each.value.associate_web_acl, var.defaults.associate_web_acl, false)
8+
connection_logs = try(each.value.connection_logs, var.defaults.connection_logs, {})
89
create = try(each.value.create, var.defaults.create, true)
910
create_security_group = try(each.value.create_security_group, var.defaults.create_security_group, true)
1011
customer_owned_ipv4_pool = try(each.value.customer_owned_ipv4_pool, var.defaults.customer_owned_ipv4_pool, null)

0 commit comments

Comments
 (0)