VPC Tutorial
VPC Tutorial
Configure Custom Amazon VPC and provision web server in public subnet
of the VPC.
Objectives:
Step 1: In AWS Management Console, go to VPC service. In VPC side Panel, click
Your VPCs. Your default VPC is visible in this window. Click on Create VPC.
In VPC settings:
Keep rest default, scroll down and click on Create VPC. In the next successful
creation window, click on Actions -> Edit DNS Hostnames.
www.cloud-plusplus.com/aws-training
Page 1|
Cloud Plus Plus Services
Check the Enable box and Save changes.
Step 2: Go back to VPC dashboard. Click on Subnets. Here there would be existing
subnets of default VPC. Click on Create Subnets.
(The above values may vary according to your own region, subnets and
requirements)
www.cloud-plusplus.com/aws-training
Page 2|
Cloud Plus Plus Services
Keep the rest values default, scroll down and click on Create Subnet.
Check the Enable auto assign public IPv4 address. And click Save.
www.cloud-plusplus.com/aws-training
Page 3|
Cloud Plus Plus Services
Go back to Subnets, click on Create Subnets. Select myVPC from drop down.
(The above values may vary according to your own region, subnets and
requirements)
Step 3: In VPC console side panel, go to Internet Gateways. Click on Create internet
gateway.
Keep the defaults as is, scroll down and click on Create internet gateway.
www.cloud-plusplus.com/aws-training
Page 4|
Cloud Plus Plus Services
Select myVPC from drop down and click on Attach internet gateway.
Step 4: Go back to VPC service console. Select Route Tables. Here we create 2 route
tables.
www.cloud-plusplus.com/aws-training
Page 5|
Cloud Plus Plus Services
Follow the same procedure to create Private route table.
Step 5: Go back to Subnets. Select myPublicSN. Go to Actions -> Edit route table
associations.
www.cloud-plusplus.com/aws-training
Page 6|
Cloud Plus Plus Services
Configure as follows:
Destination: 0.0.0.0/0
Step 6: In VPC console side panel, click Security Groups under Security.
Configure it as follows:
www.cloud-plusplus.com/aws-training
Page 7|
Cloud Plus Plus Services
Add three rules under Inbound Rules:
1. Type: HTTP
Source: 0.0.0.0/0
2. Type: HTTP
Source: ::/0
3. Type: SSH
Source: 0.0.0.0/0
After adding the rules, scroll down and click on Create security group.
Now also create a database security group. Go to Security Groups under Security.
1. Type: SSH
Source: 0.0.0.0/0
2. Type: MYSQL/Aurora
Source: MyWebServerSG (The Security group created above for ec2
webserver instance creation)
After adding the rules, scroll down and click on Create security group.
www.cloud-plusplus.com/aws-training
Page 8|
Cloud Plus Plus Services
Step 7: In VPC console, go to NAT Gateways. Click on Create NAT gateway.
Configure as follows:
Name: myNATGW
Subnet: myPublicSN
Destination: 0.0.0.0/0
Target: myNATGW
www.cloud-plusplus.com/aws-training
Page 9|
Cloud Plus Plus Services
Network: myVPC
Subnet: myPublicSN
Scroll down to Advanced Details. Under User data, in the text box, provide the
following script:
#!/bin/bash
yum -y update
yum -y install httpd
chkconfig httpd on
service httpd start
echo "<html><h1>Hello! How are You? This is your Web
Server!</h1></html>" > /var/www/html/index.html
www.cloud-plusplus.com/aws-training
P a g e 10 |
Cloud Plus Plus Services
Key: Name
Value: MyWebServerForVPC
In next step, click on Select exiting security groups radio button. Select the
MyWebServerSG created previously.
Copy the Public IPv4 address, run it in a different tab and test the web server
instance.
If you no longer need this infrastructure, make sure to dissociate and release the
elastic IP address, delete the EC2 instance, NAT gateway and the custom VPC.
www.cloud-plusplus.com/aws-training
P a g e 11 |
Cloud Plus Plus Services
www.cloud-plusplus.com/aws-training
P a g e 12 |