Other Articles

Load Balancer – Enable Access Logs

Secure Configuration Checks > AWS

This check ensures that access logs are enabled for Application Load Balancers and Network Load Balancers. Access logs record each request or connection that reaches the load balancer, such as the client IP address, the time and the response. Without them, you cannot trace attacks, investigate incidents or show who accessed your applications.

Check Details

  • Resource: Application Load Balancer and Network Load Balancer
  • Check: Enable load balancer access logs (AccessLogsEnabled)
  • Risk: Malicious or unusual traffic leaves no record, and incident response has no request-level evidence

Where access logs can be sent

  • Amazon S3: Works for Application and Network Load Balancers. Low cost, and you can query the logs with Amazon Athena.
  • Amazon CloudWatch Logs: Works for Application Load Balancers only, through vended log delivery. Good for searching and alarms.

Remediation via AWS Console

  1. Log in to the AWS Management Console and open the Amazon EC2 console.

    Amazon EC2 Console
  2. In the left navigation pane, under Load Balancing, click Load Balancers and select the affected load balancer.
  3. Open the Attributes tab and click Edit.

    Load balancer attributes tab
  4. Turn on Access logs. Enter the S3 location, for example s3://<bucket-name>/<prefix>. To let AWS create the bucket and its policy, select Create this location for me.

    Edit access logs of a load balancer
  5. Click Save changes.
  6. Repeat steps 2 to 5 for every Application and Network Load Balancer without access logs.

Remediation via AWS CLI

  1. Log in to the AWS Management Console and click the CloudShell icon (>_) in the top-right corner.

    AWS CloudShell
  2. List the Application and Network Load Balancers that do not send access logs to S3:

    for arn in $(aws elbv2 describe-load-balancers \
      --query 'LoadBalancers[?Type==`application` || Type==`network`].LoadBalancerArn' \
      --output text); do
      aws elbv2 describe-load-balancer-attributes \
        --load-balancer-arn "$arn" \
        --query "Attributes[?Key=='access_logs.s3.enabled'].Value" \
        --output text | grep -qx true || echo "$arn"
    done
    

    The command covers one region. Add --region <region> to each aws command to check another. An Application Load Balancer that delivers logs only to CloudWatch Logs is also listed. Skip it if you have confirmed that delivery.

  3. Allow the load balancer service to write to the bucket. Skip this step if the bucket already has a suitable policy:

    cat > policy.json <<'EOF'
    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Principal": {"AWS": "arn:aws:iam::<elb-account-id>:root"},
          "Action": "s3:PutObject",
          "Resource": "arn:aws:s3:::<bucket-name>/<prefix>/AWSLogs/<account-id>/*"
        }
      ]
    }
    EOF
    
    aws s3api put-bucket-policy \
    --bucket <bucket-name> \
    --policy file://policy.json
    

    The <elb-account-id> depends on the region. Find it in the AWS documentation for load balancer access logs. Regions opened after August 2022 use a service principal instead of an account ID, and Network Load Balancers use a different policy. The console option Create this location for me handles all of these cases.

  4. Enable access logs:

    aws elbv2 modify-load-balancer-attributes \
    --load-balancer-arn <load-balancer-arn> \
    --attributes \
    Key=access_logs.s3.enabled,Value=true \
    Key=access_logs.s3.bucket,Value=<bucket-name> \
    Key=access_logs.s3.prefix,Value=<prefix>
    
  5. Verify the access log attributes:

    aws elbv2 describe-load-balancer-attributes \
    --load-balancer-arn <load-balancer-arn> \
    --query "Attributes[?starts_with(Key, 'access_logs')]" \
    --output table
    

    The value of access_logs.s3.enabled must be true. Log files can take several minutes to appear in the bucket.

Replace <load-balancer-arn> with the ARN of the load balancer. Replace <bucket-name> and <prefix> with your S3 bucket and a folder name, and <account-id> with your 12-digit AWS account ID. Repeat steps 3 and 4 for each load balancer, or for each bucket you use.

Updated on 04 November, 2026