CLoud Computing Lab Manual
CLoud Computing Lab Manual
LAB MANUAL
Cloud Computing
(AL-604(A))
NAME:
ENROLLMENT NUMBER:
SESSION: 2024-25
Page 1 of 59
List of Experiment
Sr. Date of
No Experiment Perform Grade Signature Remark
. ance
Create a Linux Server in AWS EC2 and Connect to it
1 Securely
Page 2 of 59
Evaluation Sheet
Student Name :
Subject Name :
Subject Code:
Practical Record Execution & Record
Completion Result Viva Submission
(6 marks) (6 marks) (4 marks) (4 marks)
Record
Complete Record Proper Output Answer
with correct syntax 6 for all program 6 Correctly 4 submitted in 4 Total
S. time
Name of Experiment Complete Record Proper Output Answer Record not out of
No with improper 4 for some 4 Satisfactoril 2 submitted in 2 20
syntax program y time
Partially Complete Unable to Record Not
Record 2 Partial Output 2 Answer 0 Submitted 0
Output not
Incomplete Record 0 shown 0
Create a Linux Server in AWS
1 EC2 and Connect to it Securely
Deployment Webpage on
4 windows Server in AWS.
Grand Total
Marks out of 20
Page 3 of 59
Experiment No.1
Create a Linux Server in AWS and Connect to it Securely
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides
resizable compute capacity in the cloud. It is designed to make web-scale cloud
computing easier for developers.
Amazon EC2's simple web service interface allows you to obtain and configure
capacity with minimal friction. It provides you with complete control of your
computing resources and lets you run on Amazon's proven computing
environment. Amazon EC2 reduces the time required to obtain and boot new
server instances to minutes, allowing you to quickly scale capacity, both up and
down, as your computing requirements change.
Amazon EC2 changes the economics of computing by allowing you to pay only for
capacity that you actually use. Amazon EC2 provides developers the tools to build
failure resilient applications and isolate themselves from common failure scenarios.
Page 4 of 59
• Launch a web server with termination protection enabled
• Modify the security group that your web server is using to allow HTTP access
• Resize your Amazon EC2 instance to scale and enable stop protection
Note: Verify that your EC2 console is currently managing resources in the N.
Virginia (us-east-1) region. You can verify this by looking at the drop down
menu at the top of the screen, to the left of your username. If it does not
already indicate N. Virginia, choose the N. Virginia region from the region
menu before proceeding to the next step.
The Name you give this instance will be stored as a tag. Tags enable you to
categorize your AWS resources in different ways, for example, by purpose,
Page 5 of 59
owner, or environment. This is useful when you have many resources of the
same type — you can quickly identify a specific resource based on the tags
you have assigned to it. Each tag consists of a Key and a Value, both of which
you define. You can define multiple tags to associate with the instance if you
want to.
In this case, the tag that will be created will consist of a key called Name with a
value of Web Server
o A template for the root volume for the instance (for example, an
operating system or an application server with applications)
o Launch permissions that control which AWS accounts can use the AMI
to launch instances
o A block device mapping that specifies the volumes to attach to the
instance when it is launched
The Quick Start list contains the most commonly-used AMIs. You can also
create your own AMI or select an AMI from the AWS Marketplace, an online
store where you can sell or buy software that runs on AWS.
Page 6 of 59
type includes one or more instance sizes, allowing you to scale your resources
to the requirements of your target workload.
The t2.micro instance type has 1 virtual CPU and 1 GiB of memory.
The Lab VPC was created using an AWS CloudFormation template during the
setup process of your lab. This VPC includes two public subnets in two
different Availability Zones.
Note: Keep the default subnet PublicSubnet1. This is the subnet in which
the instance will run. Notice also that by default, the instance will be assigned
a public IP address.
13. Under Firewall (security groups), choose Create security group and
configure:
o Security group name: Web Server security group
o Description: Security group for my web server
A security group acts as a virtual firewall that controls the traffic for one
or more instances. When you launch an instance, you associate one or
more security groups with the instance. You add rules to each security
group that allow traffic to or from its associated instances. You can
modify the rules for a security group at any time; the new rules are
Page 7 of 59
automatically applied to all instances that are associated with the
security group.
o Under Inbound security group rules, notice that one rule exists.
Remove this rule.
You will launch the Amazon EC2 instance using a default 8 GiB disk volume.
This will be your root volume (also known as a 'boot' volume).
17. Scroll to the bottom of the page and then copy and paste the code shown
below into the User data box:
#!/bin/bash
dnf install -y httpd
systemctl enable httpd
systemctl start httpd
echo '<html><h1>Hello From Your Web Server!</h1></html>' > /var/www/html/index.html
Step 8: Launch the instance
Page 8 of 59
o In the Instances list, select Web Server.
The instance is assigned a Public IPv4 DNS that you can use to contact the instance
from the Internet.
At first, the instance will appear in a Pending state, which means it is being
launched. It will then change to Initializing, and finally to Running.
With instance status monitoring, you can quickly determine whether Amazon
EC2 has detected any problems that might prevent your instances from
running applications. Amazon EC2 performs automated checks on every
running EC2 instance to identify hardware and software issues.
Notice that both the System reachability and Instance reachability checks
have passed.
This tab displays Amazon CloudWatch metrics for your instance. Currently,
there are not many metrics to display because the instance was recently
launched.
Page 9 of 59
You can choose the three dots icon in any graph and select Enlarge to see an
expanded view of the chosen metric.
Amazon EC2 sends metrics to Amazon CloudWatch for your EC2 instances.
Basic (five-minute) monitoring is enabled by default. You can also enable
detailed (one-minute) monitoring.
23. In the Actions menu towards the top of the console, select Monitor and
troubleshoot Get system log.
The System Log displays the console output of the instance, which is a
valuable tool for problem diagnosis. It is especially useful for troubleshooting
kernel problems and service configuration issues that could cause an
instance to terminate or become unreachable before its SSH daemon can be
started. If you do not see a system log, wait a few minutes and then try
again.
24. Scroll through the output and note that the HTTP package was installed from
the user data that you added when you created the instance.
25. Choose Cancel.
26. Ensure Web Server is still selected. Then, in the Actions menu, select
Monitor and troubleshoot Get instance screenshot.
27. Choose Cancel.
28. Ensure Web Server is still selected. Choose the Details tab.
29. Copy the Public IPv4 address of your instance to your clipboard.
30. Open a new tab in your web browser, paste the IP address you just copied,
then press Enter.
31. Keep the browser tab open, but return to the EC2 Console tab.
Page 10 of 59
32. In the left navigation pane, choose Security Groups.
33. Select Web Server security group.
34. Choose the Inbound rules tab.
35. Choose Edit inbound rules , select Add rule and then configure:
o Type: HTTP
o Source: Anywhere-IPv4
o Choose Save rules
36. Return to the web server tab that you previously opened and refresh the
page.
You should see the message Hello From Your Web Server!
When you stop an instance, it is shut down. There is no runtime charge for a
stopped EC2 instance, but the storage charge for attached Amazon EBS volumes
remains.
37. On the EC2 Management Console, in the left navigation pane, choose
Instances and then select the Web Server instance.
38. In the Instance state menu, select Stop instance.
39. Choose Stop
Your instance will perform a normal shutdown and then will stop running.
Page 11 of 59
40. Wait for the Instance state to display: Stopped.
When the instance is started again it will run as a t2.small, which has
twice as much memory as a t2.micro instance. NOTE: You may be
restricted from using other instance types in this lab.
42. Select the Web Server instance, then in the Actions menu , select Instance
settings Change stop protection. Select Enable and then Save the change.
When you stop an instance, the instance shuts down. When you later start
the instance, it is typically migrated to a new underlying host computer and
assigned a new public IPv4 address. An instance retains its assigned private
IPv4 address. When you stop an instance, it is not deleted. Any EBS volumes
and the data on those volumes are retained.
The disk volume currently has a size of 8 GiB. You will now increase the size
of this disk.
45. Change the size to: 10 NOTE: You may be restricted from creating Amazon
EBS volumes larger than 10 GB in this lab.
46. Choose Modify
47. Choose Modify again to confirm and increase the size of the volume.
Page 12 of 59
Experiment No.2
Deployment of website on Linux Server in AWS.
In the AWS Management Console, in the search box next to Services, search for
and choose Service Quotas
1. Choose AWS services from the navigation menu and then in the AWS
services Find services search bar, search for ec2 and choose Amazon Elastic
Compute Cloud (Amazon EC2).
2. In the Find quotas search bar, search for running on-demand , but do not
make a selection. Instead, observe the filtered list of service quotas that
match the criteria.
Notice that there are limits on the number and types of instances that can
run in a region. For example, there is a limit on the number of Running On-
Demand Standard... instances that you can launch in this region. When
launching instances, the request must not cause your usage to exceed the
instance limits currently defined in that region.
Page 13 of 59
Task 6: Test Stop Protection
You can stop your instance when you do not need to access but you would still like
to retain it. In this task, you will learn how to use stop protection.
1. In the AWS Management Console, in the search box next to Services, search
for and choose EC2 to return to the EC2 console.
2. In left navigation pane, choose Instances.
3. Select the Web Server instance and in the Instance state menu, select Stop
instance.
4. Then choose Stop
a. Note that there is a message that says: Failed to stop the instance i-
1234567xxx. The instance 'i-1234567xxx' may not be stopped. Modify its
'disableApiStop' instance attribute and try again.
b. This shows that the stop protection that you enabled earlier in this lab
is now providing a safeguard to prevent the accidental stopping of an
instance. If you really want to stop the instance, you will need to
disable the stop protection.
5. In the Actions menu, select Instance settings Change stop protection.
6. Remove the check next to Enable.
7. Choose Save
a. You can now stop the instance.
8. Select the Web Server instance again and in the Instance state menu,
select Stop instance.
9. Choose Stop
10. After creating the instances
11. Goto EC2 and create linux instance
12. use following commands to deploy your code
sudo su -
yum update -y
Page 14 of 59
mkdir temp
cd temp
mv * /var/www/html (Now move all your files from temp folder to root directory)
ls -lrt (to check files are moved from temp to root directory)
Copy public ip of your instance in URL to check your code is deployed in EC2.
Page 15 of 59
Experiment No.3
• AWS account
• IAM user with EC2 permissions
• Key pair for RDP access
3. Launch Instance
o Choose AMI:
o Instance type:
o Key pair:
o Network settings:
2. Open port 3389 (RDP) only from your IP address (for security)
Page 16 of 59
4. Launch instance
o Username: Administrator
Page 17 of 59
o Check firewall is enabled on the Windows Server
3. Regular maintenance:
Page 18 of 59
Experiment No.4
Deployment Webpage on windows Server in AWS.
Page 19 of 59
o Copy your index.html (and other files like images, CSS, etc.) into
C:\inetpub\wwwroot
o Add rule:
o Type: HTTP
o Port: 80
o Save rules
o Enter:
o cpp
o CopyEdit
o http://<Public-IP-of-EC2-instance>
Page 20 of 59
Experiment No.5
Create the web service using SOAP
I hope you know the meaning of web service before you execute the demo. A web
service is nothing but a software application that runs on the web having some
exposed web methods that other applications can use over HTTP/ HTTPS protocols
using technologies such as XML, SOAP, WSDL, and UDDI. Here in this demo, we will
create one such web service and we will try to use its web methods. We will do all of
this in a single web project but you can try it in different projects on the same
machines as well as different projects on different machines. It should work.
Once you click on Project, you will see the following pop-up window.
Page 21 of 59
Step 2. Here, choose ASP.NET Web Application (.NET Framework) and give it a name
as I have given - WebServiceProject. Click on OK.
Page 22 of 59
Step 3. Once you click on the New Item, choose Web Service and give it a name as
given below.
Page 23 of 59
Step 4. Now, write the following code in WebService.asmx file.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace WebServiceProject
{
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
Page 24 of 59
// To allow this Web Service to be called from script, using ASP.NET AJAX,
uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public int Add(List<int> listInt)
{
int result = 0;
for (int i = 0; i < listInt.Count; i++)
{
result = result + listInt[i];
}
return result;
}
}
}
Here, WebMethod HelloWorld comes by default when you create a web service.
You can change its implementation if you want. We have implemented another
method that can take a list of integers as input and will give you some of all the lists
of integers given as input.
Now, if you run this project and point the URL to WebService.asmx, then you will
get the following result, which indicates that your web service has been created.
Page 25 of 59
Now you can find all the descriptions of services written on this page having
the list of methods which are available via this web service. You can also see the
service description to get a better picture. If you will click methods, then you will see
its soap request response structures and for simple generic methods, you will also
see an option to invoke methods.
Page 26 of 59
Experiment No.6
Consume the Web Service in Web Based Application in Microsoft Visual Studio
There are multiple ways to do that. We will here try to use it via a web reference
method. We will add a Web reference for this service in our project for
consumption.
To add a Web reference of this service in the project, right-click on the project and
click "Add Service Reference". Once you do that you will see the following popup
window.
So here we have entered the path to the web service and once you click on Go you
will see the service structure like this. You can also see methods exposed by clicking
on Web Service over here. Just give it a namespace name that you want to use. For
Page 27 of 59
us, we are using ServiceReference1. Click OK and it will add a service reference of
this web service in your project.
For this, I will add a webform page to our project. Here I have added WebForm.aspx
having a button and a label. What I want to do here is on click of a button in this
webform I should get the sum of an integer list using our web service method. So
the code looks like below in WebForm.aspx.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" style="height:
26px" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
In WebForm.aspx.cs, I have written a handler like this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebServiceProject.ServiceReference1;
namespace WebServiceProject
{
public partial class WebForm : System.Web.UI.Page
{
Page 28 of 59
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
WebService webService = new WebService();
List<int> lstIntegers = new List<int> { 5, 6, 7 };
Label1.Text = "Output of WebService: " + webService.Add(lstIntegers).ToString();
} }}
So now, if you run this project and point to this webform, you will get the sum of all
these hardcoded 3 integers' lists using the Add method. The output of this comes
as below after clicking the button on the page.
Page 29 of 59
Experiment No.7
Create and manage users, security credentials such as access keys, and
permissions using AWS Identity and Access Management (IAM)
AWS Identity and Access Management (IAM) is a web service that enables
Amazon Web Services (AWS) customers to manage users and user permissions in
AWS. With IAM, you can centrally manage users, security credentials such as
access keys, and permissions that control which AWS resources users can access.
Page 30 of 59
AWS Identity and Access Management
AWS Identity and Access Management (IAM) can be used to:
• Manage IAM Users and their access: You can create Users and assign them
individual security credentials (access keys, passwords, and multi-factor
authentication devices). You can manage permissions to control which
operations a User can perform.
• Manage IAM Roles and their permissions: An IAM Role is similar to a User,
in that it is an AWS identity with permission policies that determine what the
identity can and cannot do in AWS. However, instead of being uniquely
associated with one person, a Role is intended to be assumable by anyone
who needs it.
• Manage federated users and their permissions: You can enable identity
federation to allow existing users in your enterprise to access the AWS
Management Console, to call AWS APIs and to access resources, without the
need to create an IAM User for each identity.
Tip: To refresh the session length at any time, choose Start Lab again
before the timer reaches 0:00.
o Before you continue, wait until the circle icon to the right of the AWS
link in the upper-left corner turns green.
2. To connect to the AWS Management Console, choose the AWS link in the
upper-left corner.
o A new browser tab opens and connects you to the console.
Tip: If a new browser tab does not open, a banner or icon is usually at
the top of your browser with the message that your browser is
preventing the site from opening pop-up windows. Choose the banner
or icon, and then choose Allow pop-ups.
Page 31 of 59
3. Arrange the AWS Management Console tab so that it displays along side
these instructions. Ideally, you will be able to see both browser tabs at the
same time, to make it easier to follow the lab steps.
In this task, you will explore the Users and Groups that have already been created
for you in IAM.
4. In the search box to the right of Services, search for and choose IAM to open
the IAM console.
5. In the navigation pane on the left, choose Users.
user-1
o
o user-2
o user-3
6. Choose the user-1 link.
This will bring to a summary page for user-1. The Permissions tab will be
displayed.
o EC2-Admin
o EC2-Support
Page 32 of 59
oS3-Support
10. Choose the EC2-Support group link.
This will bring you to the summary page for the EC2-Support group.
13. Choose the plus (+) icon next to the AmazonEC2ReadOnlyAccess policy to
view the policy details.
16. Choose the S3-Support group link and then choose the Permissions tab.
17. Choose the plus (+) icon to view the policy details.
This policy grants permissions to Get and List resources in Amazon S3.
18. Choose the minus icon (-) to hide the policy details.
Page 33 of 59
20. Choose the EC2-Admin group link and then choose the Permissions tab.
This Group is slightly different from the other two. Instead of a Managed
Policy, it has an Inline Policy, which is a policy assigned to just one User or
Group. Inline Policies are typically used to apply permissions for one-off
situations.
21. Choose the plus (+) icon to view the policy details.
22. Choose the minus icon (-) to hide the policy details.
You wish to give access to new staff depending upon their job function:
You have recently hired user-1 into a role where they will provide support for
Amazon S3. You will add them to the S3-Support group so that they inherit the
necessary permissions via the attached AmazonS3ReadOnlyAccess policy.
In the Users tab you will see that user-1 has been added to the group.
Page 34 of 59
Add user-2 to the EC2-Support Group
You have hired user-2 into a role where they will provide support for Amazon EC2.
28. Using similar steps to the ones above, add user-2 to the EC2-Support group.
29. Using similar steps to the ones above, add user-3 to the EC2-Admin group.
Each Group should now have a 1 in the Users column, indicating the number
of Users in each Group.
If you do not have a 1 beside each group, revisit the above instructions above
to ensure that each user is assigned to a User group, as shown in the table in
the Business Scenario section.
A Sign-in URL for IAM users in this account link is displayed on the right. It
will look similar to: https://123456789012.signin.aws.amazon.com/console
This link can be used to sign-in to the AWS Account you are currently using.
32. Copy the Sign-in URL for IAM users in this account to a text editor.
33. Open a private (Incognito) window.
Page 35 of 59
Mozilla Firefox
Google Chrome
Microsoft Edge
Next, you will sign-in as user-1, who has been hired as your Amazon S3
storage support staff.
Since your user is part of the S3-Support Group in IAM, they have permission
to view a list of Amazon S3 buckets and the contents.
Page 36 of 59
38. In the search box to the right of Services, search for and choose EC2 to open
the EC2 console.
39. In the left navigation pane, choose Instances.
You cannot see any instances. Instead, you see a message that states You are
not authorized to perform this operation. This is because this user has not
been granted any permissions to access Amazon EC2.
You will now sign-in as user-2, who has been hired as your Amazon EC2
support person.
40. Sign user-1 out of the AWS Management Console by completing the
following actions:
o At the top of the screen, choose user-1
o Choose Sign Out
41. Paste the IAM users sign-in link into your private browser tab's address bar
and press Enter.
Page 37 of 59
You are now able to see an Amazon EC2 instance because you have Read
Only permissions. However, you will not be able to make any changes to
Amazon EC2 resources.
If you cannot see an Amazon EC2 instance, then your Region may be
incorrect. In the top-right of the screen, pull-down the Region menu and
select the region that you noted at the start of the lab (for example, N.
Virginia).
48. In the search box to the right of Services, search for and choose S3 to open
the S3 console.
You will see the message You don't have permissions to list buckets
because user-2 does not have permission to access Amazon S3.
You will now sign-in as user-3, who has been hired as your Amazon EC2
administrator.
49. Sign user-2 out of the AWS Management Console by completing the
following actions:
o At the top of the screen, choose user-2
o Choose Sign Out
Page 38 of 59
50. Paste the IAM users sign-in link into your private window and press Enter.
51. Paste the sign-in link into the address bar of your private web browser tab
again. If it is not in your clipboard, retrieve it from the text editor where you
stored it earlier.
52. Sign-in with:
o IAM user name: user-3
o Password: Lab-Password3
53. In the search box to the right of Services, search for and choose EC2 to open
the EC2 console.
54. In the navigation pane on the left, choose Instances.
If you cannot see an Amazon EC2 instance, then your Region may be
incorrect. In the top-right of the screen, pull-down the Region menu and
select the region that you noted at the start of the lab (for example, N.
Virginia).
The instance will enter the stopping state and will shutdown.
Page 39 of 59
Experiment No.8
Create and Manage code in S3 bucket and Deploy it in EC2 Linux Server on
AWS
Step1 - Firstly Create S3 bucket put your code in S3 bucket and copy the URL.
1. sudo su -
2. yum update -y
7. mkdir temp
8. cd temp
11. ls -lrt (To check your unzip files are deployed in temp folder)
12. mv * /var/www/html (Now move all your files from temp folder to root
directory)
13. ls -lrt (to check files are moved from temp to root directory)
13. cd complex (Goto Your folder, Here complex is my folder's name, Code is
deployed to EC2 instance )
14. Copy public ip of your instance in URL to check your code is deployed in EC2.
Page 40 of 59
Experiment No.9
Architecture Amazon Virtual Private Cloud (Amazon VPC) enables you to launch
Amazon Web Services (AWS) resources into a virtual network that you defined. This
virtual network closely resembles a traditional network that you would operate in
your own data center, with the benefits of using the scalable infrastructure of AWS.
You can create a VPC that spans multiple Availability Zones.
Create a VPC.
Create subnets.
Configure a security group.
Launch an EC2 instance into a VPC.
To connect to the AWS Management Console, choose the AWS link in the upper-left
corner.
Page 41 of 59
In the search box to the right of Services, search for and choose VPC to open the
VPC console.
Note: If you do not see a button with that name, choose the Launch
VPC Wizard button instead.
(e) Configure the VPC details in the VPC settings panel on the left:
(f) Choose VPC and more.
(g) Under Name tag auto-generation, keep Auto-generate selected,
however change the value from project to lab .
(h) Keep the IPv4 CIDR block set to 10.0.0.0/16
(i) For Number of Availability Zones, choose 1.
(j) For Number of public subnets, keep the 1 setting.
(k) For Number of private subnets, keep the 1 setting.
(l) Expand the Customize subnets CIDR blocks section
(m) Change Public subnet CIDR block in us-east-1a to
10.0.0.0/24
(n) Change Private subnet CIDR block in us-east-1a to
10.0.1.0/24
(o) Set NAT gateways to In 1 AZ.
(p) Set VPC endpoints to None.
(q) Keep both DNS hostnames and DNS resolution enabled.
(r) In the Preview panel on the right, confirm the settings you have configured.
(s) VPC: lab-vpc
(t) Subnets:
(u) us-east-1a
(v) Public subnet name: lab-subnet-public1-us-east-1a
(w) Private subnet name: lab-subnet-private1-us-east-
1a
(x) Route tables
(y) lab-rtb-public
(z) lab-rtb-private1-us-east-1a
(aa) Network connections
Page 42 of 59
(bb) lab-igw
(cc) 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.
Page 43 of 59
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.
In this task, you will create two additional subnets for the VPC in a second
Availability Zone. Having subnets in multiple Availability Zones within a VPC is useful
for deploying solutions that provide High Availability.
After creating a VPC as you have already done, you can still configure it further, for
example, by adding more subnets. Each subnet you create resides entirely within
one Availability Zone.
The second public subnet was created. You will now create a second private
subnet.
Page 44 of 59
1. VPC ID: lab-vpc
2. Subnet name: lab-subnet-private2
3. Availability Zone: Select the second Availability Zone (for example, us-
east-1b)
4. IPv4 CIDR block: 10.0.3.0/24
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.
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.
Page 45 of 59
1. Leave lab-subnet-private1-us-east-1a selected, but also select lab-subnet-
private2.
2. Choose Save associations
You will now configure the Route Table that is used by the Public Subnets.
3. Select the lab-rtb-public route table (and deselect any other subnets).
4. In the lower pane, choose the Routes tab.
You will now associate this route table to the second public subnet you
created.
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.
Page 46 of 59
instance. You can add rules to each security group that allow traffic to or from its
associated instances.
You will use this security group in the next task when launching an Amazon
EC2 instance.
In the search box to the right of Services, search for and choose EC2 to open the
EC2 console.
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.
Page 47 of 59
The type of Amazon Machine Image (AMI) you choose determines the
Operating System that will run on the EC2 instance that you launch.
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.
#!/bin/bash
# Install Apache Web Server and PHP
dnf install -y httpd wget php mariadb105-server
# Download Lab files
Page 48 of 59
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.
9. At the bottom of the Summary panel on the right side of the screen choose
Launch instance
Wait until Web Server 1 shows 2/2 checks passed in the Status check
column.
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.
Page 49 of 59
Experiment No.10
Auto Scaling helps you maintain application availability and allows you to scale
your Amazon EC2 capacity out or in automatically according to conditions you
define. You can use Auto Scaling to help ensure that you are running your desired
number of Amazon EC2 instances. Auto Scaling can also automatically increase the
number of Amazon EC2 instances during demand spikes to maintain performance
and decrease capacity during lulls to reduce costs. Auto Scaling is well suited to
applications that have stable demand patterns or that experience hourly, daily, or
weekly variability in usage.
Page 50 of 59
Task 1: Create an AMI for Auto Scaling
In this task, you will create an AMI from the existing Web Server 1. This will save the
contents of the boot disk so that new instances can be launched with identical
content.
6. Wait until the Status Checks for Web Server 1 displays 2/2 checks passed. If
necessary, choose refresh to update the status.
You will use this AMI when launching the Auto Scaling group later in the lab.
Page 51 of 59
Task 2: Create a Load Balancer
In this task, you will first create a target group and then you will create a load
balancer that can balance traffic across multiple EC2 instances and Availability
Zones.
Analysis: Target Groups define where to send traffic that comes into the Load
Balancer. The Application Load Balancer can send traffic to multiple Target
Groups based upon the URL of the incoming request, such as having
requests from mobile apps going to a different set of servers. Your web
application will use only one Target Group.
Note: Targets are the individual instances that will respond to requests from
the Load Balancer.
You do not have any web application instances yet, so you can skip this step.
You will now specify which subnets the Load Balancer should use. The
load balancer will be internet facing, so you will select both Public
Subnets.
o Choose the first displayed Availability Zone, then select Public Subnet
1 from the Subnet drop down menu that displays beneath it.
Page 52 of 59
o Choose the second displayed Availability Zone, then select Public
Subnet 2 from the Subnet drop down menu that displays beneath it.
You should now have two subnets selected: Public Subnet 1 and
Public Subnet 2.
The Web Security Group security group should now be the only one
that appears.
19. For the Listener HTTP:80 row, set the Default action to forward to
LabGroup.
20. Scroll to the bottom and choose Create load balancer
Page 53 of 59
o Launch template name: LabConfig
o Under Auto Scaling guidance, select Provide guidance to help me set up
a template that I can use with EC2 Auto Scaling
o In the Application and OS Images (Amazon Machine Image) area,
choose My AMIs.
o Amazon Machine Image (AMI): choose Web Server AMI
o Instance type: choose t2.micro
o Key pair name: choose vockey
o Firewall (security groups): choose Select existing security group
o Security groups: choose Web Security Group
o Scroll down to the Advanced details area and expand it.
o Scroll down to the Detailed CloudWatch monitoring setting. Select
Enable
o Choose Create launch template
Next, you will create an Auto Scaling group that uses this launch
template.
Page 54 of 59
29. Configure the details in Step 4 (Configure group size and scaling policies -
optional):
o Under Group size, configure:
▪ Desired capacity: 2
▪ Minimum capacity: 2
▪ Maximum capacity: 6
o Under Scaling policies, choose Target tracking scaling policy and
configure:
▪ Scaling policy name: LabScalingPolicy
▪ Metric type: Average CPU Utilization
▪ Target value: 60
o Choose Next
30. Configure the details in Step 5 (Add notifications - optional):
Auto Scaling can send a notification when a scaling event takes place. You will
use the default settings.
o Choose Next
31. Configure the details in Step 6 (Add tags - optional):
Page 55 of 59
Task 4: Verify that Load Balancing is Working
In this task, you will verify that Load Balancing is working correctly.
You should see two new instances named Lab Instance. These were
launched by Auto Scaling.
If the instances or names are not displayed, wait 30 seconds and choose
refresh in the top-right.
Next, you will confirm that the new instances have passed their Health
Check.
Two target instances named Lab Instance should be listed in the target
group.
Healthy indicates that an instance has passed the Load Balancer's health
check. This means that the Load Balancer will send traffic to the instance.
You can now access the Auto Scaling group via the Load Balancer.
Page 56 of 59
41. Open a new web browser tab, paste the DNS Name you just copied, and
press Enter.
The application should appear in your browser. This indicates that the Load
Balancer received the request, sent it to one of the EC2 instances, then
passed back the result.
42. Return to the AWS Management Console, but do not close the application tab
— you will return to it soon.
43. in the search box next to Services , search for and select CloudWatch.
44. In the left navigation pane, choose All alarms.
Two alarms will be displayed. These were created automatically by the Auto
Scaling group. They will automatically keep the average CPU load close to
60% while also staying within the limitation of having two to six instances.
Note: Please follow these steps only if you do not see the alarms in 60
seconds.
Page 57 of 59
45. Choose the OK alarm, which has AlarmHigh in its name.
If no alarm is showing OK, wait a minute then choose refresh in the top-right
until the alarm status changes.
The OK indicates that the alarm has not been triggered. It is the alarm for
CPU Utilization > 60, which will add instances when average CPU is high. The
chart should show very low levels of CPU at the moment.
You will now tell the application to perform calculations that should raise the
CPU level.
This will cause the application to generate high loads. The browser page will
automatically refresh so that all instances in the Auto Scaling group will
generate load. Do not close this tab.
In less than 5 minutes, the AlarmLow alarm should change to OK and the
AlarmHigh alarm status should change to In alarm.
You can choose Refresh in the top-right every 60 seconds to update the
display.
49. Wait until the AlarmHigh alarm enters the In alarm state.
You can now view the additional instance(s) that were launched.
50. In the search box next to Services , search for and select EC2.
51. In the left navigation pane, choose Instances.
More than two instances labeled Lab Instance should now be running. The
new instance(s) were created by Auto Scaling in response to the CloudWatch
alarm.
Page 58 of 59
Task 6: Terminate Web Server 1
In this task, you will terminate Web Server 1. This instance was used to create the
AMI used by your Auto Scaling group, but it is no longer needed.
52. Select Web Server 1 (and ensure it is the only instance selected).
53. In the Instance state menu, choose Instance State > Terminate Instance.
54. Choose Terminate
Page 59 of 59