Create a public and private subnet. Create two instances (one in each subnet) and the instance in private subnet should get internet. Instance in private subnet should allow traffic only from public subnet.

  1. Create a VPC:

    • Go to the AWS Management Console and navigate to the VPC dashboard.
    • Click on "Create VPC" and enter the required details, such as the VPC name, CIDR block, etc.
  2. Create Subnets:

    • Navigate to the "Subnets" section of the VPC dashboard.
    • Click on "Create subnet" and enter the required details, such as the subnet name, VPC ID, CIDR block, availability zone, etc.
    • Create two subnets, one for public and one for private.
  3. Create Internet Gateway:

    • Navigate to the "Internet Gateways" section of the VPC dashboard.
    • Click on "Create internet gateway" and enter the required details, such as the internet gateway name.
    • Attach the internet gateway to the VPC.
  4. Route Tables:

    • Navigate to the "Route Tables" section of the VPC dashboard.
    • Create two route tables, one for each subnet.
    • Associate the public subnet with the default route table.
    • Associate the private subnet with the new route table.
  5. Create Security Groups:

    • Navigate to the "Security Groups" section of the VPC dashboard.
    • Create two security groups, one for each instance.
    • Configure the security group for the instance in the public subnet to allow all traffic from any IP address.
    • Configure the security group for the instance in the private subnet to allow traffic only from the security group for the instance in the public subnet.
  6. Launch Instances:

    • Navigate to the "Instances" section of the EC2 dashboard.
    • Launch two instances, one in each subnet.
    • During the launch process, choose the appropriate security group and subnet for each instance.
    • Configure the instance in the private subnet to use a NAT gateway to access the internet.

After following these steps, you should have a public and private subnet with two instances, where the instance in the private subnet can access the internet and the instance in the public subnet can access the instance in the private subnet, but not vice versa.

Comments

Popular posts from this blog

Error Solving : -bash: /usr/local/bin/kubectl: cannot execute binary file : after Kubernetes installation: you're trying to run the kubectl command on an EC2 instance in AWS

Nodejs Application project : using Aws, Jenkins, Docker, Kubernetes

Create two public subnets and two private subnets in two different availability zones(AZ) ( one public and one private subnet in each AZ).Create an instance of webserver (like apache ) in each AZ and an instance of db server in any AZ. Attach web servers to ELB and make sure to support cross zone availability.