Prerequisite: Ensure you have an active AWS account and permissions to create and manage VPCs, EC2 instances, and Flow Logs.
Step 1: Create a VPC
To create a Virtual Private Cloud (VPC), follow the steps below:Tip: If you plan to use private subnets, consider adding NAT Gateways for internet access from private instances.
Step 2: Launch an EC2 Instance
Now that your VPC is ready, launch an EC2 instance within it:- Navigate to the EC2 console and click Launch Instances.
- Configure the instance with these details:
- Name:
Instance - MyVPC Project. - Amazon Machine Image (AMI): Select Amazon Linux 2023 AMI.
- Instance Type:
t2.micro(eligible for free tier). - Network settings:
- Select the MyVPC VPC.
- Choose the public subnet created earlier.
- Enable public IP auto-assignment.
- Security group: Create a new group called
SG - MyVPC Project:- Add an inbound rule to allow SSH traffic (port 22) from your IP.
- Name:
Step 3: Enable Flow Logs
Flow Logs allow you to monitor network traffic for your VPC. Follow these steps to enable them:- Go to the VPC console, select your VPC, and open the Flow Logs tab.
- Click Create Flow Log and configure:
- Filter:
All. - Destination:
CloudWatch Logs. - Create or select an IAM role that allows VPC to publish logs to CloudWatch.
- Filter:
Viewing Logs in CloudWatch
Once Flow Logs are enabled, you can monitor network traffic in CloudWatch:- Open the CloudWatch console and select Log Groups.
- Find your log group (e.g.,
MyFlowLogs) and explore the entries. - Analyze the data to identify unusual traffic patterns or troubleshoot connectivity.
Troubleshooting
I don't see any data in Flow Logs
I don't see any data in Flow Logs
Ensure:
- The IAM role has the correct permissions to publish logs to CloudWatch.
- There is traffic in the VPC (test by using commands like
pingorcurlfrom your instance).
EC2 instance is not accessible via SSH
EC2 instance is not accessible via SSH
Verify:
- The instance is in a public subnet and has a public IP assigned.
- The security group has an inbound rule to allow SSH traffic from your IP.
- Your local machine allows outgoing SSH traffic.
Conclusion
Youβve successfully:- Created a VPC.
- Launched an EC2 instance within the VPC.
- Enabled Flow Logs to monitor network traffic.
π§ Contact
For questions or feedback, reach out: π¨ Email: [email protected] π Portfolio: Brian Kimemia GitHub: BrianKN019Thank you for exploring this project! Letβs innovate and build secure AWS solutions together. π