5.3 Setup Our EC2 Instances - Lab
In this lab, we will set up the EC2 instances that will be used in the following lectures.
Steps:
Create Region 1 EC2 instances
Go to EC2. We will provision 2 t2-micro instances in the region that is closest to you and we are going to provision an ELB.
We you create instances, leave everything as default, except copy the bootstrap code (can be found on Udemy) and paste it to the Advanced Details -> User data, which will automatically help you to update operating system, and install Apache httpd server, and start the server, and set chkconfig to be on, and create a webpage index.html which shows "This the web server #1" at /var/www/html/ directory when you launch the instance.
Leave Add storage as default.
Add a tag for this web server #1.
Use the existing security group which allows the traffic of HTTP, SSH, HTTPS.
Review and launch using the existed key pair.
Do the steps above again to launch web server #2.
Create Region 1 ELB
Create a ELB and put the two instances behind of this ELB.
Go to ELB and click classic load balancer, and click continue.
Give a name to the ELB and leave other things as default and click Next.
Put the ELB in the same security group as the two instances.
Configure the health check, the Ping path should be /index.html and the Interval could be 10 seconds and healthy threshold could be 3. Click Next.
Add the two EC2 instances to this ELB and click Next.
Add a tag for your ELB.
You can visit the two instance through their IP address or through the DNS name of the ELB. If you visit through the ELB, you get an equal possibility to be directed to web server #1 or #2.
Create Region 2 EC2 instance
Go to another Region (the further from your current Region is the better).
Go to EC2, use t2-micro, leave everything as default, except copy the bootstrap code (can be found on Udemy) and paste it to the Advanced Details -> User data, change the content of index.html to be "This the web server #1 in a far away Region".
Leave other as default, give a tag to the instance and click next.
Create a new security group (because in a new Region, you probably have not created any security group yet). Add rule: HTTP, SSH, HTTPS. Click next.
You may also need to create new key pairs in a new Region. Download the key pair and click launch.
Create Region 2 ELB
Go to ELB, and use classic LB. Give a name to your ELB and leave other things as default. Click next.
Use the same security group of EC2 instance to the ELB. Click next.
In the health check, change the interval to be 10 seconds and change the healthy threshold to be 3. Click next.
Add the EC2 instance you launched just now to the ELB. Click next until create the ELB.
You can visit the instance through its IP address or through the DNS name of the ELB.
Now you are ready to do the Route53 labs in the following lectures.
Last updated
Was this helpful?