This rule focuses on enabling VPC flow logging in all VPCs to enhance security measures.
Rule | Ensure VPC flow logging is enabled in all VPCs |
Framework | cis_v150 |
Severity | ✔ High |
Rule Description:
The rule "cis_v150" requires enabling VPC flow logging for all VPCs in order to enhance security monitoring and compliance within an Amazon Web Services (AWS) infrastructure. VPC flow logging captures network traffic metadata, allowing visibility into communication patterns and potential security threats.
Troubleshooting Steps:
If VPC flow logging is not enabled for a VPC, follow these troubleshooting steps:
Check if the VPC Flow Logs feature is supported in your AWS region. Not all AWS regions support VPC Flow Logs. Refer to AWS documentation to confirm availability in your region.
Verify that the VPC has a flow log configuration. Flow log configurations define the settings for capturing and storing flow log data. To check the configuration, navigate to the VPC management console, select the desired VPC, and verify if a flow log is associated. If not, proceed to the remediation steps.
Check if the VPC has the necessary IAM permissions for creating and writing logs to Amazon CloudWatch Logs. Ensure that the appropriate IAM policy has been attached to the IAM role associated with the VPC. If required permissions are missing, modify the role or create a new one with the necessary permissions.
Ensure that the subnet(s) associated with the VPC have an active flow log. Flow logs can be configured at the subnet level as well. Check the subnet configuration to confirm if the flow log is enabled. If not, proceed with the required steps to enable flow log configuration.
Remediation Steps:
To enable VPC flow logging for all VPCs, follow these steps:
Open the AWS Management Console and navigate to the Amazon VPC service.
Select each VPC that does not have flow logs enabled.
Click on the "Actions" button and select "Create Flow Log" from the dropdown menu.
Configure the flow log settings:
Click on "Create Flow Log" to enable flow logs for the selected VPC.
Repeat the above steps to enable flow logs for all VPCs that do not have it enabled.
Additional Notes:
Manual Script:
If you prefer using AWS CLI commands, follow the steps below:
aws ec2 describe-vpcs --query "Vpcs[?not_null(FlowLogs[].FlowLogId)] | [?not_null(FlowLogs[].FlowLogId == '')].{VpcId:VpcId}"
aws ec2 create-flow-logs --resource-ids VPC_ID --resource-type VPC --traffic-type ALL --log-destination-type cloud-watch-logs --log-destination ARN --log-group-name LOG_GROUP_NAME --log-stream-name LOG_STREAM_NAME
Replace:
VPC_ID
with the actual VPC ID.ARN
with the ARN of the IAM role permitting flow log creation and writing to Amazon CloudWatch Logs.LOG_GROUP_NAME
with the desired name for your CloudWatch Logs group.LOG_STREAM_NAME
with the desired name for your CloudWatch Logs stream.Note: Ensure that the AWS CLI is configured with necessary permissions and credentials to perform the above commands.