Thursday, May 24, 2018



AWS Autoscaling demo lab






Configuring VPC, Public/Private subnets, Internet Gateway (IGW), NAT gateway, etc.,
 Created VPC with CIDR block  10.10.0.0/16





Created two public subnet in AZ1 and AZ2
Rengs-Public -1A: 10.10.1.0/24
Rengs-Public-1B : 10.10.2.0/24
Created two private subnet in AZ3 and AZ4
Rengs-Private-1C: 10.10.3.0/24
Rengs-Private-1D: 10.10.4.0/24
Created two Route Table [ Rengs-Public-RT and 
Rengs-Private-RT]

Created on Internet Gateway (Rengs-IGW)  and I attached this to VPC (Rengs-VPC)



Create NAT GW for Rengs-Public-1A  with Elastic IP and attached this  to Routing Table (Rengs-private-RT)
                0.0.0.0/0 -> NAT GW
                Associate Rengs-Private-RT route table to two private subnets

Add 0.0.0.0/0 -> IGW in Rengs-Public-RT route table.
                Associate two public subnets to Rengs-Public-RT route table.
aws ec2 attach-internet-gateway --vpc-id "vpc-bfbc90c4" --internet-gateway-id "igw-d1e294a9" --region us-east-1
2. Create EC2 instance with below userdata/Bootstrapping script
#!/bin/bash
yum install httpd -y
service httpd start
chkconfig httpd on
yum install wget -y
yum install php php-mysql mysql -y
Create webserver-SG and  allow SSH and HTTP port
Create IAM role for EC2 with S3 access (Rengs-S3-Fullaccess)

Create a SNS topic and subscription to your email ID.
Attach IAM role(Rengs-S3-Fullaccess) to your new Webserver
Create RDS-SG security group and give access to webserver -SG



Create classic LoadBalacer (Rengs-ELB) -open port 80 and map both public-subnet

5. Install wordpress
[ec2-user@ip-10-10-1-77 ~]$
[ec2-user@ip-10-10-1-77 ~]$ sudo su -
[root@ip-10-10-1-77 ~]# cd /var/www/html
[root@ip-10-10-1-77 html]# wget https://wordpress.org/latest.tar.gz
--2018-05-14 03:06:07--  https://wordpress.org/latest.tar.gz
Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8565154 (8.2M) [application/octet-stream]
Saving to: ‘latest.tar.gz’
latest.tar.gz       100%[===================>]   8.17M  20.1MB/s    in 0.4s
2018-05-14 03:06:08 (20.1 MB/s) - ‘latest.tar.gz’ saved [8565154/8565154]
[root@ip-10-10-1-77 html]# ls
latest.tar.gz
[root@ip-10-10-1-77 html]# tar -xvf latest.tar.gz
[root@ip-10-10-1-77 wordpress]# ls
index.php    wp-activate.php     wp-comments-post.php  wp-cron.php        wp-load.php   wp-settings.php   xmlrpc.php
license.txt  wp-admin            wp-config-sample.php  wp-includes        wp-login.php  wp-signup.php
readme.html  wp-blog-header.php  wp-content            wp-links-opml.php  wp-mail.php   wp-trackback.php
 [root@ip-10-10-1-77 wordpress]# mv * /var/www/html/

[root@ip-10-10-1-77 html]# cd /etc/httpd/conf
[root@ip-10-10-1-77 conf]# ls
httpd.conf  magic
[root@ip-10-10-1-77 conf]# vi httpd.conf
(search  "AllowOverride None" Change none to All )

Change permissions on html directory
                chown -R apache:apache /var/www/

Test RDS instance conncetion from your webserver EC2 instance
mysql -h rengsdb.cidtkwwtk7hg.us-east-1.rds.amazonaws.com -u rengsdb -p
Enter password:
mysql> CREATE DATABASE rengsdb;
Query OK, 1 row affected (0.01 sec)

7. Create new IAM role and S3 bucket
8.Assign IAM role to EC2 instance and copy application data to S3
9.Create Route53 hosted zone to map with domain

Route53 Configuration
Create Hosted zone and Recordset for your Domain www.rengscloud.com

and go to Godaddy.com where you registered your domain name and add AWS DNS details
ManageDNS -> Name servers -> custom -> add AWS DNS Nameservers






















10.Create AMI for EC2 instance











13. Enable ACM in ELB
14. Secure infra at Security Group and VPC level

AWS Autoscaling demo lab Configuring VPC, Public/Private subnets, Internet Gateway (IGW), NAT gateway, etc.,   Crea...