This repository shows a test infrastructure in the AWS cloud.
We will create VPC, 4 Subnets and place the EC-2 instance inside the subnet.
We will also install a webserver on the EC-2 instance and access it using a web browser.
1. Create the VPC with the CIDR Block Range 10.0.0.0/16 (65000 Hosts)
2.Create an Internet Gateway and attach it to the newly created VPC
3.Create Public Subnet-1 in Availability Zone-1 with the CIDR 10.0.0.0/24
4.Create Private Subnet-1 in Availability Zone-1 with CIDR of 10.0.1.0/24
5.Create an Elastic IP.
6.Create a NAT Gateway using the Elastic IP and Public Subnet -1 as base
7.Create Public Subnet-2 in Availability Zone-2 with the CIDR 10.0.2.0/24
8.Create Private Subnet-2 in Availability Zone-2 with the CIDR 10.0.3.0/24
9.Update Route Configurations for present Route Table and name it Private Route Table
10.Create Public Route Table and update Route Configurations
11.Create VPC Security Group to allow inbound HTTP,HTTPS and SSH
12.Create EC-2 Instances using the VPC Created as base and the Public Subnet-1 as EC-2 Location.
13.Enable Public IP for the EC-2
14.Associate the VPC Security Group for the EC-2
15.Update User Data for the EC-2
16.Launch EC-2
17.Test Webserver running on EC-2 using a browser.
After completing the above steps, you can successfully complete this work using the following guide:
1. Create the VPC with the CIDR Block Range 10.0.0.0/16 (65000 Hosts).
2. Create an Internet Gateway and attach it to the newly created VPC
3. Create Public Subnet -1 in Availability zone -1 with the CIDR 10.0.0.0/24
4. Create Private Subnet -1 in Availability Zone -1 with CIDR of 10.0.1.0/24
5. Create an Elastic IP.
6. Create a NAT Gateway using the Elastic IP using the Public Subnet -1 as base
7. Create Public Subnet -2 in Availability zone -2 with the CIDR 10.0.2.0/24
8. Create Private Subnet -2 in Availability Zone -2 with the CIDR 10.0.3.0/24
9. Update Route Configurations for present Route Table and name it Private Route Table
Update Private Route Table Route’s as follows
Destination | Target |
---|---|
10.0.0.0/16 | Local |
0.0.0.0/0 | NAT Gateway |
Create Public Route Table and update Route Configurations.
10. Create Public Route Table and update Route Configurations.
11. Create VPC Security Group to allow inbound HTTP,HTTPS and SSH
-
Create EC-2 Instances using the VPC Created as Base and the Public Subnet-1 as EC-2 Location.
-
Enable Public IP for the EC-2
-
Associate the VPC Security Group for the EC-2
-
Update User Data for the EC-2 (Check paragraph 17)
Doublececk our Public Routes:
Doublececk our Private Routes:
15. Launch EC-2
- Connect by SSH:
- Follow these commands after a successful connection:
(Or make a .sh file give chmod and run)((Or use like User data))
#!/bin/bash
sudo su
yum update
# Install Apache Web Server and PHP
yum install -y httpd
yum install -y mysql
yum install -y php
# Download Lab files
wget https://github.com/san-vivt/VPC-DevOps-project/raw/main/src/lab-app-san.zip
unzip lab-app-san.zip -d /var/www/html/
# Turn on web server
chkconfig httpd on
service httpd start
Enter to our WEB page:
http://<our_instance_ip>
Enter the magic command in terminal, just for fun, to load our one CPU core of the instance to 100%
(# -- mean root user)((For remove this load make # killall yes ))
# yes > /dev/null &
Voila, BOOM!