Description
ALB access logs describe requests. For an NLB, S3 access logs cover TLS connections on TLS listeners.
Potential impact
Without the relevant records, it is harder to trace errors or unexpected traffic at the load balancer.
Remediation
Set enabled = true in access_logs, specify the destination bucket and prefix, and allow log delivery in the bucket policy. Send traffic through the listener and check for a new access log under that prefix.
Examples
This ALB writes to the test-lb prefix. Supply the referenced network resources, bucket and delivery policy separately.
Before
hcl
resource "aws_lb" "example" {
name = "test-lb-tf"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.lb_sg.id]
subnets = [for subnet in aws_subnet.public : subnet.id]
access_logs {
bucket = aws_s3_bucket.lb_logs.id
prefix = "test-lb"
enabled = false
}
}
After
hcl
resource "aws_lb" "example" {
name = "test-lb-tf"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.lb_sg.id]
subnets = [for subnet in aws_subnet.public : subnet.id]
access_logs {
bucket = aws_s3_bucket.lb_logs.id
prefix = "test-lb"
enabled = true
}
}