Complete Guide to Setting Up EC2 Instances, VPC, Route Tables, Public Subnets, and More on AWS

  1. Create 2 EC2 Instances:
  • Go to the EC2 Dashboard on the AWS Management Console.
  • Click on “Launch Instance” to create a new EC2 instance.
  • Choose an Amazon Machine Image (AMI), instance type, configure instance details, add storage, configure security groups, and review the instance.
  • Repeat the process to launch the second EC2 instance.
  1. Create a VPC (Virtual Private Cloud):
  • In the VPC Dashboard, click on “Create VPC”.
  • Provide a name and CIDR block for your VPC.
  • Configure additional settings if necessary and create the VPC.
  1. Create a Route Table:
  • In the Route Tables section of the VPC Dashboard, click on “Create Route Table”.
  • Select your VPC, give it a name, and create the route table.
  • Edit the route table to add routes as needed, such as to the internet gateway.
  1. Create Public Subnets for EC2 Instances:
  • In the Subnets section of the VPC Dashboard, click on “Create Subnet”.
  • Select your VPC, choose an availability zone, specify the CIDR block, and create the subnet.
  • Ensure that “Auto-assign IPv4” is enabled to assign public IP addresses to instances in this subnet.
  • Repeat this process to create another public subnet in a different availability zone.
  1. Create a Target Group:
  • Go to the Target Groups section of the EC2 Dashboard.
  • Click on “Create target group”.
  • Provide a name, select the protocol, port, and configure health checks.
  • Add your EC2 instances to the target group.
  1. CIDR Blocks:
  • You’ve already defined CIDR blocks when creating the VPC and subnets. Ensure they don’t overlap and are appropriate for your network.
  1. Create Security Groups:
  • For EC2 Instances: In the Security Groups section of the EC2 Dashboard, click on “Create security group”. Define inbound and outbound rules as per your requirements. Make the EC2 instances accessible only to the load balancer traffic (For the inbound rules, add a type “All TCP” and Protocol “TCP” point to the security group for the load balancer).
  • For Load Balancer: Similarly, create a security group for your load balancer and define rules to allow traffic as necessary. In this case, we are allowing all traffic from the public.
  1. Create an Internet Gateway:
  • In the Internet Gateways section of the VPC Dashboard, click on “Create internet gateway”.
  • Attach the internet gateway to your VPC.
  • Update the route table associated with your public subnets to route internet-bound traffic to the internet gateway.

Once you’ve completed these steps, you’ll have set up the infrastructure as described. Remember to configure all components according to your specific requirements and security best practices.

Leave a Comment

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

Scroll to Top