DEV Community

Jessica Tiwari
Jessica Tiwari

Posted on

Automating the EC2 Instance

This week, as a part of MS2V Technologies, we embarked on a small yet informative project focusing on automating the E2 web server using user data. The main objective was to launch an EC2 instance that would automatically install NGINX and display a simple message in the browser, eliminating the need for manual intervention.

Architecture Design

The architecture design was straightforward. The user would connect to the public IP through which the EC2 instance was configured. Once connected, NGINX would be installed, and our simple HTML page would load.

Launching the EC2 Instance
To initiate this project, I first launched an EC2 instance by selecting the appropriate AMI (Amazon Machine Image). Given that this was a basic project with minimal content, I opted for a T2.micro instance.

Network and Security Setup
While configuring the network and security group, I allowed SSH access from my IP on port 22 and HTTP traffic from anywhere through port 80. This restriction ensures secure access for SSH while allowing the browser to load my web page seamlessly.

User Data Script
The user data script created for this project was minimal, focusing on displaying a simple text message upon accessing the web server.

Creating a baked AMI
After successfully connecting to the instance and verifying that NGINX was operational, I created a baked AMI to the existing EC2 instance configuration. This process taking a snapshot of the instance's volume, which resulted in a new AMI that can be reused to launch future instances without the need for manual setup.

Conclusion
Overall, this project was an excellent opportunity to understand the features of AMIs and the automation capabilities within AWS. The ability to launch instances with pre-installed software and configurations greatly simplifies the process, making rapid deployment of web servers both efficient and reliable.

Top comments (0)