My Experience with the AWS Capstone Project (cloud architecting course)
Published: 2023-04-05 16:12:49

**Introduction:** 
Recently, I completed the AWS Cloud Architecting Course. At the end of the course there’s a capstone project as a way to demonstrate/implement the skills and knowledge learned during the course.
I wanted to create this post as a way to document my current progress on my cloud journey and talk through some of my thinking behind the solution to this project. As part of this project, I worked with EC2 instances, Load Balancers, Amazon RDS, MySQL databases, and Bastion Hosts.


**The problem:**
The project has a fairly lengthy brief/backstory, but we can boil it down to the following: Currently an organisation is hosting their web server and MySQL database on a single EC2 instance. They need a solution that is highly available and secure.

**Our Starting point:**
We’re given an environment where a bastion host has been set up, and multiple security groups have been configured.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5j6y4agmjbt19cmzroly.png)


**My Solution:**
The first step I took was to understand what our final product would look like and mapped it out in the diagram below. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k41oegub4xpnhc45if9.png)

Our solution needed to be *highly available* to deal with increasing popularity, as such I decided to put the App Servers in an autoscaling group behind a load balancer. This allows our resources to scale horizontally based on demand and ensures that those accessing the site have a good experience. Additionally, I opted to use a multi-AZ deployment for our MySQL database to add resiliency to our solution. This means that the website is still able to function fully even if one of the availability zones becomes unavailable. 

Our solution also needed to be *secure*, therefore, I opted to place the app servers in a private subnet and have access to them via the Application Load balancer. The security groups for each component are configured to restrict inbound traffic to ensure each component is as isolated as it needs to be. We can provide secure SSH admin access to our app servers via the bastion host located in the public subnet. Database connection information can be securely stored using AWS parameter store. 

**Implementing the solution:**
Once I understood what the end goal was, implementing the solution was fairly straightforward. AWS kindly already supplied us with a launch template for the application server. The launch template contained user data that installed and started a LAMP server, as well as downloading a MySQL dump file and all the files needed for the website.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5k0392694hb1i3pe056d.png)

My first action was to set up the SSH connection to the app server via the bastion host. This was a concept that I had previously struggled with in practice earlier in the course, however, now that I had done it a few times it was easily manageable.

Once I had established that connection, I set about creating a MySQL database on an RDS instance. AWS has a nice feature that asks if you want to connect an EC2 instance to the database. I connected my app server and AWS saved me the job of having to configure the security groups to allow traffic between the database and app servers!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pv0kabkf2kc3j1v91k5q.png)

Once the database was set up, I connected to it from my app server and imported in the data from the MySQL dump. It was my first time doing this and so it took a little troubleshooting (and a lot of reading) to understand how to do it!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kln64ynwcv8gy5pmsktw.png)

The next step was to create and application load balancer, an autoscaling group for my app servers, and associate the two. I then wanted to test if my solution worked. So I navigated to the DNS of the load balancer and SUCCESS! The web page displayed! However, when I tried to run a query I was getting an error message.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hir2frayd9nn1fd8ipsi.png)

I understood that there must be an issue between the connection between the web app and the RDS database. I realised that I had forgotten to add the parameters to parameter store. Upon adding the parameters and testing again, it worked!! (I'll admit, the 'database' parameter had me a little confused to begin with, but I got there in the end!) 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mjtcye43cuthjbx2py9q.png)

**Conclusion:**
Overall, the project was a great way for me to consolidate a range of different skills, as well as learn a few new ones! I really enjoyed this project and found it to be an extremely valuable experience, even if it did have me stumped at a couple of points! I learned some new things about databases and how to incorporate them with web apps, I'm looking forward to learning more as I go onwards with my cloud journey! 

Thanks for reading!