Lab 11
Lab 11
4. In the search box to the right of Services, search for and choose VPC to open the
VPC console.
5. Begin creating a VPC.
o In the top right of the screen, verify that N. Virginia (us-east-1) is the region.
o Choose the VPC dashboard link which is towards the top left of the console.
o Next, choose Create VPC.
Note: If you do not see a button with that name, choose the Launch VPC Wizard
button instead.
6. Configure the VPC details in the VPC settings panel on the left:
o Choose VPC and more.
o Under Name tag auto-generation, keep Auto-generate selected, however change
the value from project to lab .
o Keep the IPv4 CIDR block set to 10.0.0.0/16
o For Number of Availability Zones, choose 1.
o For Number of public subnets, keep the 1 setting.
o For Number of private subnets, keep the 1 setting.
o Expand the Customize subnets CIDR blocks section
▪ Change Public subnet CIDR block in us-east-1a to 10.0.0.0/24
▪ Change Private subnet CIDR block in us-east-1a to 10.0.1.0/24
o Set NAT gateways to In 1 AZ.
o Set VPC endpoints to None.
o Keep both DNS hostnames and DNS resolution enabled.
7. In the Preview panel on the right, confirm the settings you have configured.
o VPC: lab-vpc
o Subnets:
▪ us-east-1a
▪ Public subnet name: lab-subnet-public1-us-east-1a
▪ Private subnet name: lab-subnet-private1-us-east-1a
o Route tables
▪ lab-rtb-public
▪ lab-rtb-private1-us-east-1a
o Network connections
▪ lab-igw
▪ lab-nat-public1-us-east-1a
The VPC resources are created. The NAT Gateway will take a few minutes to
activate.
Please wait until all the resources are created before proceding to the next step.
The wizard has provisioned a VPC with a public subnet and a private subnet in one
Availability Zone with route tables for each subnet. It also created an Internet
Gateway and a NAT Gateway.
To view the settings of these resources, browse through the VPC console links that
display the resource details. For example, choose Subnets to view the subnet
details and choose Route tables to view the route table details. The diagram below
summarizes the VPC resources you have just created and how they are configured.
An Internet gateway is a VPC resource that allows communication between EC2
instances in your VPC and the Internet.
The lab-subnet-public1-us-east-1a public subnet has a CIDR of 10.0.0.0/24, which
means that it contains all IP addresses starting with 10.0.0.x. The fact the route table
associated with this public subnet routes 0.0.0.0/0 network traffic to the internet
gateway is what makes it a public subnet.
A NAT Gateway, is a VPC resource used to provide internet connectivity to any EC2
instances running in private subnets in the VPC without those EC2 instances
needing to have a direct connection to the internet gateway.
The second public subnet was created. You will now create a second private subnet.
You will now configure this new private subnet to route internet-bound traffic to the
NAT Gateway so that resources in the second private subnet are able to connect to
the Internet, while still keeping the resources private. This is done by configuring a
Route Table.
A route table contains a set of rules, called routes, that are used to determine where
network traffic is directed. Each subnet in a VPC must be associated with a route
table; the route table controls routing for the subnet.
Note that Destination 0.0.0.0/0 is set to Target nat-xxxxxxxx. This means that
traffic destined for the internet (0.0.0.0/0) will be sent to the NAT Gateway. The NAT
Gateway will then forward the traffic to the internet.
This route table is therefore being used to route traffic from private subnets.
You created this route table in task 1 when you chose to create a VPC and multiple
resources in the VPC. That action also created lab-subnet-private-1 and associated
that subnet with this route table.
Now that you have created another private subnet, lab-subnet-private-2, you will
associate this route table with that subnet as well.
19. In the Explicit subnet associations panel, choose Edit subnet associations
You will now configure the Route Table that is used by the Public Subnets.
22. Select the lab-rtb-public route table (and deselect any other subnets).
You will now associate this route table to the second public subnet you created.
25. In the Explicit subnet associations area, choose Edit subnet associations
Your VPC now has public and private subnets configured in two Availability Zones.
The route tables you created in task 1 have also been updated to route network
traffic for the two new subnets.
Task 3: Create a VPC Security Group
In this task, you will create a VPC security group, which acts as a virtual firewall.
When you launch an instance, you associate one or more security groups with the
instance. You can add rules to each security group that allow traffic to or from its
associated instances.
32. Scroll to the bottom of the page and choose Create security group
You will use this security group in the next task when launching an Amazon EC2
instance.
33. In the search box to the right of Services, search for and choose EC2 to open the
EC2 console.
34. From the Launch instance menu choose Launch instance.
When you name your instance, AWS creates a tag and associates it with the
instance. A tag is a key value pair. The key for this pair is *Name*, and the value is
the name you enter for your EC2 instance.
The type of Amazon Machine Image (AMI) you choose determines the Operating
System that will run on the EC2 instance that you launch.
The Instance Type defines the hardware resources assigned to the instance.
The vockey key pair you selected will allow you to connect to this instance via SSH
after it has launched. Although you will not need to do that in this lab, it is still
required to identify an existing key pair, or create a new one, or choose to proceed
without a key pair, when you launch an instance.
Note: The default settings specify that the root volume of the instance, which will
host the Amazon Linux guest operating system that you specified earlier, will run on
a general purpose SSD (gp3) hard drive that is 8 GiB in size. You could alternatively
add more storage volumes, however that is not needed in this lab.
#!/bin/bash
# Install Apache Web Server and PHP
dnf install -y httpd wget php mariadb105-server
# Download Lab files
wget https://aws-tc-largeobjects.s3.us-west-2.amazonaws.com/CUR-TF-100-ACCLFO-2/2-lab2-
vpc/s3/lab-app.zip
unzip lab-app.zip -d /var/www/html/
# Turn on web server
chkconfig httpd on
service httpd start
This script will run with root user permissions on the guest OS of the instance. It will
run automatically when the instance launches for the first time. The script installs a
web server, a database, and PHP libraries, and then it downloads and installs a PHP
web application on the web server.
42. At the bottom of the Summary panel on the right side of the screen choose Launch
instance
This may take a few minutes. Choose the refresh icon at the top of the page every
30 seconds or so to more quickly become aware of the latest status of the instance.
You will now connect to the web server running on the EC2 instance.
46. Copy the Public IPv4 DNS value shown in the Details tab at the bottom of the page.
47. Open a new web browser tab, paste the Public DNS value and press Enter.
You should see a web page displaying the AWS logo and instance meta-data
values.