This rule ensures VPC flow logging is enabled in all VPCs.
Rule | Ensure VPC flow logging is enabled in all VPCs |
Framework | cis_v140 |
Severity | ✔ Critical |
Rule Details
Rule Name: Enable VPC Flow Logging for cis_v140
Description: VPC flow logging allows you to capture information about the IP traffic going to and from network interfaces in your VPC. This rule ensures that VPC flow logging is enabled for all VPCs in compliance with the cis_v140 security benchmark.
This rule is implemented to enhance the visibility of network traffic within AWS VPCs and improve security by logging all network traffic information.
Troubleshooting Steps
Check if the VPC flow logs are enabled:
Verify IAM permissions:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowVPCFlowLogs", "Effect": "Allow", "Action": [ "ec2:CreateFlowLogs", "ec2:DescribeFlowLogs" ], "Resource": "*" } ] }
Check VPC settings:
Code Examples
Python Boto 3 SDK:
import boto3
ec2_client = boto3.client('ec2')
def enable_flow_logs(vpc_id):
response = ec2_client.create_flow_logs(
ResourceIds=[vpc_id],
ResourceType='VPC',
TrafficType='ALL',
LogDestinationType='cloud-watch-logs',
LogDestination='arn:aws:logs:region:account-id:log-group:log-group-name',
DeliverLogsPermissionArn='arn:aws:iam::account-id:role/role-name'
)
print(response)
# Usage
vpc_id = 'your-vpc-id'
enable_flow_logs(vpc_id)
AWS CLI:
aws ec2 create-flow-logs --resource-type VPC --resource-ids your-vpc-id --traffic-type ALL --log-destination-type cloud-watch-logs --log-destination 'arn:aws:logs:region:account-id:log-group:log-group-name' --deliver-logs-permission-arn 'arn:aws:iam::account-id:role/role-name'
Remediation Steps
To enable VPC flow logging for cis_v140, follow the step-by-step guide:
Ensure that flow logs are configured and enabled for all VPCs in compliance with the cis_v140 security benchmark.