Web Server Wars 2 — the Bank Strikes back!!

Steven Jones
4 min readAug 15, 2023

--

As a continuation of developing my cloud skills, my next assignment came from Level Up In Tech comes in the form of deploying a web server onto an Centos Server using Apache as the web server. Let’s continue the journey…

Level Up Bank was thrilled with the work that I did with moving their static website to AWS via the S3 Buckets as documented here, but the next phase of their journey with transitioning to the cloud would involve moving their actual on-premise Apache web servers to EC2 instances in the cloud. Their OS of preference is Centos 7 so they want to ensure that the instances are all Centos 7.

In an effort of ensuring some deployment standardization and ease, I decided that the deployment would be best handled by leveraging CloudFormation. So that I can ensure that the appropriate people can access the CloudFormation template.

So I thought about the pieces it would take to deploy and access a Centos 7 Web Server…

Actual picture inside Steven’s brain…

After dousing the flames… it was clear. I needed what they asked — Centos 7, Apache and some web content. Simple enough, right?

If I were to do this by hand, what would it take?

Finding a Centos AMI, deploying it with the appropriate security group to allow for access to the http port and the ssh port for remote access.

Found my AMI (had to run thru the communities):

So I came up with the following little CF Template to accomplish this.

Resources:
LinuxInstance:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: us-east-1a
ImageId: ami-006f9342f66f4167a
InstanceType: t2.micro
KeyName: LUIT_Linux
SecurityGroups:
- !Ref CentosSecurityGroup
UserData:
Fn::Base64: |
#!/bin/bash
yum update -y
yum install httpd -y
systemctl start httpd
systemctl enable httpd
cd /var/www/html
echo '<html><html><head><style>h1 {text-align: center;}p {text-align: center;}div {text-align: center;}</style><title>LUIT Work!</title></head><body><center><img src="https://www.levelupintech.com/static/8bc964ae0f1d91c8cc90510ac60afdac/497c6/logo.png" alt="Level Up In Tech Logo"></center><p></p><p></p><h1>Welcome to LUIT - Gold Team</h1><p></p><p></p><p></p><p>The journey continues!!</p><p></p><p></p><p></p></body></html>' > index.html
CentosSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: SSH and HTTP
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: 22
IpProtocol: tcp
ToPort: 22
- CidrIp: 0.0.0.0/0
FromPort: 80
IpProtocol: tcp
ToPort: 80

I saved it as a file and uploaded the file to an S3 bucket:

In order to use this I’ll need that Object URL so I copied it using the double squares to copy it. I then used the link to deploy a CF stack.

Ok — The stack is started and I keep an eye on the status:

It’s finished deploying so I want to ssh into the Centos instance to verify that the user data scripts are completed deploying.

To connect, I could plunge through the AWS console over to EC2 and get the connection info, but I remebered a bit from my last project that would get me the public IP/DNS name of the EC2 instance just deployed.

So we have the instance public DNS name which the name includes the IP address (in this case 44.212.17.217).

So I ssh into the box, using the IP name and user name centos since this is centos and check to see whether yum has deployed httpd (Apache).

I check the IP just to be sure that things kick off…

And we’re 100% deployed!!

After presenting this to the Gold Team, they were thrilled and satisfied with the work done and the ability to automate the delivery of the content with the deployment of the EC2 instances.

(Actual pic of Gold Team’s reaction post presentation)

--

--