In this tutorial, you'll learn how to create your own custom VPC on AWS.
—
Facebook:
https://www.facebook.com/GokceDBsql
—
Video Transcript
—
Hi guys, this is Abhi from Gokcedb. In this video, you're going to learn how to create your own custom VPC on AWS. Let's start by navigating to the VPC service then click on create VPC and give it a name enter a cider block for your VPC.
I'm going to select 10.0.0.0 with a subnet mask of 16. This should give us around 65000 IP ADDRESSES. I also want the ability to create a maximum of 250 hosts per Subnet in this VPC this means that I'll have to use the subnet mask of 24 individual subnets.
For tenancy, select default, and then it creates. Click on subnets in the left menu then click on create a subnet. Here, I'm going to create four subnets.
Two in the availability zone of US East 1A and the remaining two in U.S East 1B. In each of the two availability zones, the first Subnet will be public and the second subnet will be private. Hit the create button when done.
Click on Rout tables in the left menu and give your main route table in your VPC a name. Next, hit the create button to create a new route table for your private subnets and give it a name. Select your VPC from the drop-down then click on the create route table button.
Navigate to the subnet associations tab then click on edit. Select the two private subnets then hit save. If you navigate to the subnet association step for your main route table you'll see that your public subnets are already associated with it.
Next, click on Internet gateways in the left menu then hit create. Give it a name then click on the create button. Click on the Actions dropdown then attach to VPC. Choose your VPC then hit attach.
Go back to your main route table then click on the route tab. Click on edit routes then hit add a route. Select all zeros for the destination and the internet gateway that we just created for Target.
This will give internet connectivity to the public subnets. Next, click on net gateways in the left menu then the create button. Give it a name then select a public subnet from the drop-down.
Allocate an elastic IP then hit create. Go back to the routes tab in your private route table then hit the edit button. Click on ADD then selects all zeroes for Destination and the NAT Gateway that we just created for Target.
This will give internet connectivity to our private subnets. Next, click on security groups in the left menu then hit create. Give it a name then select your VPC.
Add an inbound rule for SSH and HTTP then hit create. Next, we're going to create four ec2 instances. One in each subnet in the public subnet will access the internet via the internet gateway and the instance in the private subnet will access the internet via the NAT Gateway.
Let's navigate to the ec2 dashboard and then click on instances. I'm going to launch the first instance in the public subnet in the US 1A availability zone. I'm going to leave all these settings to default and then click on edit in the network settings.
Select your VPC and the appropriate subnet. Enable auto-assign public IP since it's in a public subnet. Then select a security group in the user data section.
I'm going to copy-paste this startup script. In this script, I'm bringing up the httpd web server and grabbing the availability zone and subnet ID metadata, and saving it in the index.html file. Click on the launch instance and you should see a new ec2 in a pending state.
Next, I'm going to launch the ec2 instances in the remaining three subnets. Just make sure to disable the auto-assign public IP when launching an instance in a private subnet. Grab the public IP of the public one US East 1A instance and paste it into a browser.
You should see the availability zone and the subnet ID information displayed. Repeat these steps for the public to US East 1B instance. Next, let's connect to the public one US East 1A ec2 instance using instance connect.
Use the Curl command to see if you can reach the public to US 1B instance. You can also grab the private IP addresses of the two instances running in the private subnets to see if you can reach them using the curl command. You can also get more details on the subnet ID by going back to subnets and fill filtering it based on ID.
There you have it. Make sure you like, subscribe, and turn on the notification bell. Until next time.
Тэги:
#virtual_private_cloud #aws_vpc #aws_tutorial #vpc_in_aws #aws_vpc_tutorial #aws_vpc_setup #vpc_tutorial #private_subnet #public_subnet #aws_virtual_private_cloud #amazon_virtual_private_cloud #vpc_aws_tutorial #create_vpc #create_vpc_aws #aws_vpc_for_beginners #route_table