Simply put a VPC Flow Log is a feature that enables you to capture information about the traffic going to and from network interfaces in your VPC (Virtual Private Cloud).

Prerequisites

  • Ensure you have the necessary permissions to create and manage VPC Flow Logs, CloudWatch Logs, and IAM roles.
  • Have an existing VPC you want to monitor with Flow Logs.

Step 1: Create an IAM Role

  • Open the IAM console at https://console.aws.amazon.com/iam/.
  • Navigate to Roles and select Create role.
  • Choose AWS service as the type of trusted entity and select EC2.
  • Attach the AmazonEC2RoleforSSM policy and CloudWatchLogsFullAccess policy, then ¬†Click ‘Next’.
  • Give the role a name (e.g., FlowLogsRole) and create it.
Preview of the IAM Role and its Policy
Preview of the IAM Role and its Policy

Step 2: Create a CloudWatch Logs Log Group

  • Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
  • Navigate to Logs and select Create log group.
  • Name your log group (e.g., MyVPCFlowLogs).
  • Optionally, set retention settings for how long you want to keep your logs.
Creating Cloudwatch Log Group for our Flow Log
Creating Cloudwatch Log Group for our Flow Log

Step 3: Set Up Flow Logs for Your VPC

  • Open the VPC console at https://console.aws.amazon.com/vpc/.
  • In the navigation pane, select Your VPCs.
  • Select the VPC you want to monitor.
  • In the Actions dropdown, select Create flow log.
  • For Filter, choose the type of traffic to log (Accepted, Rejected, or All).
  • For Destination, select Send to CloudWatch Logs.
  • Enter the Log group name you created in Step 2.
  • For IAM role, select the role you created in Step 1.
  • Configure additional settings as needed, such as tags.
  • Click Create flow log.

Step 4: Verify Flow Log Creation

  • After creation, it may take a few minutes for logs to start appearing in your CloudWatch Logs log group.
  • Navigate to the CloudWatch console, find your log group, and check if logs are being delivered.

Important Considerations

  • Flow Logs can incur costs based on the volume of logs and the retention period in CloudWatch Logs.
  • Ensure your IAM role has the necessary permissions to create and manage Flow Logs and CloudWatch Logs.
  • Review and comply with AWS’s data retention policies and practices to manage costs and data compliance.
By following these steps, you will have successfully set up AWS Flow Logs to send logs to Amazon CloudWatch, enabling you to monitor and analyze traffic within your VPCs.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top