Note
Using AWS CloudFormation.
This whole project is made as IAC and all the templates can be used by anyone to create their own resources on cloudFormation.
1.1 : create a public S3 bucket which holds the index.html file.

The database stack was created using the aws clf and database.yaml template was used.

This S3 bucket was created.

Bucket policy.
1.2 : Connect it to an sns topic and configure it to send updates when an object is uploaded in the S3 bucket.
notification.yaml template was used to create and connect the sns topic to the S3.
You get an sns subscription confirmation email just after creating this stack.

This topic sends upload updates on the mail (index.html was uploaded).

2.1 :Create a IAM role with S3 and CloudWatch full access.
iamrole.yaml is the template used for this.

3.1 : Create a VPC with IGW , 3 public subnets , route table pointing the subnets to the IGW and a security group.
This was accomplished using networking.yaml .
This file was created using parameters which can be changed in future to create these resources with different parameters.
Vpc-info.json has the info of the VPC and its elements that were created.
4.1 :Create a User data script for the EC2 launch template(commonly used for installing software or configuring services).
user_data.sh is the User data script used in this case. It installs the httpd , aws cli and syncs the S3 to the instance.
5.1 : Create EC2 Launch Template.
The EC2 instance Configs :
- Amazon Linux ami
- T3.micro
- role with s3 and cloudwatch access
- User data script(created earlier)
- Security group(task 3.1)
instance-launchtemp.yaml does the work.
6.1 :Create auto scaling group with 2 initial instances scale out to 5 if needed, with all 3 subnets selected in the project VPC.
auto-scaling-group.yaml after this stack is created the ASG is configured and it creates the initial 2 instences.
7.1 :Create SNS topic which sends the auto scaling group status updates on specified email.
sns-instance-updates.yaml

this sends updates like these on email.
8.1 :Create Classic Load Balancer with configs :
- Public
- Project Vpc selected
- with all subnets in that vpc selected
- Security Group(task 3.1)
- Add CLB to auto scaling group
classic-load-balancer.yaml is the template to create this stack.
we have to update the ASG stack with this CLB arn for this to work.
Test to check if we get 2 different servers providing output

site 1 with different server and ip.

site 2 with different server and ip.
Increase CPU utilisation of the instances to check if the new instance is created.

increased the cpu utilisation to 100% .

average CPU utilisation of 3 instances.

New instance was initialised and created.

