Integration of VPC Flow (Network Traffic) Logs to CloudWatch for Monitoring!

What is VPC Flow Log?

Amazon VPC Flow Logs enable us to capture information about the network traffic moving to and from network interfaces within our VPC (Virtual Private Cloud). We can use VPC Flow Logs as a centralized, single source of information to monitor different network aspects of VPC. So, in other words we can detect remote logins like SSH, RDP or other network traffic going to or from VPC.

What is CloudWatch?

Amazon CloudWatch is a service used for monitoring and observing resources in real-time. CloudWatch collects monitoring and operational data in the form of logs, metrics, and events, providing its users with an aggregated view of AWS resources, applications, and services that run on AWS.

Now we will Proceed with Integration Steps:

Step 1: VPC Creation

First, we will go with VPC Creation in AWS for which we implement Flow Log service.

Step 2: Internet Gateway Creation

  1. Private Routing Table

Step 3: EC2 Instance Creation in VPC

Now we will go with creation of EC2 Instance in VPC for which we configure Flow Log and CloudWatch to monitor.

Step 4: VPC Flow Log Group Creation

We will create log group to watch specific logs related to VPC as follows:

Step 5: IAM Role Creation

Now we will create IAM Role and attach policies to accessing Logs.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principle": {
        "Service": "vpc-flow-logs.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
      "Resource": "*"
    }
  ]
}
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents",
        "logs:DescribeLogGroups",
        "logs:DescribeLogStreams"
      ],
      "Effect": "Allow",
      "Resource": "*"
    }
  ]
}

Step 6: VPC Attachment with Log Group

Now we will proceed with VPC attachment with log group to send logs to group in CloudWatch.

Conclusion:

VPC flow logs with CloudWatch offer a quick and easy insight into network traffic within the VPC. It can be used by the security team to detect and respond to network threats as they occur. Flow Log will provide visibility to the Network and Security Teams to enhance troubleshooting efforts as well as detection of suspicious capabilities.