Introduction
Launching and connecting to an AWS EC2 instance is a fundamental task for any cloud-based development or application hosting. This guide will walk you through the steps to create and connect to an EC2 instance on AWS, and then verify the connection by running some basic commands.
Prerequisites
Before starting, ensure you have an AWS account. ☁️
Step 1: Launch an EC2 Instance
Log in to your AWS Management Console. 🔑
Navigate to the EC2 Dashboard and click on "Launch Instance". 🚀
-
Configure the instance settings as follows (leave other settings as default):
- Enter the name of the EC2 Instance (e.g., "My EC2 Instance"). 🖥️
-
Select
Ubuntu
as the Amazon Machine Image (AMI). 🐧 - Create a key pair to access the instance from the command line. 🔑
-
Enter an appropriate name for the key pair. 📝
This will save the key pair file (named
ec2-instance.pem
in this case) to your local machine. 💾 - Configure the Security Group - add a rule to allow HTTP traffic (port 80). 🔒
Step 2: Connect to Your EC2 Instance
After the instance is successfully running:
Click on the
Instance ID
of the EC2 instance you just created. 🆔
On the Instance summary page, click on the
Connect
button. 🔌
Open a new local terminal from where the private key was saved. 🖥️
-
Run this command to ensure your key is not publicly viewable:
sudo chmod 400 "ec2-instance.pem"
-
Paste the command copied from Step 3 to connect to your instance:
sudo ssh -i "ec2-instance.pem" ubuntu@ec2-18-208-219-229.compute-1.amazonaws.com
Step 3: Verify Your EC2 Instance
After connecting to the EC2 instance, you can use commands as you would on your local machine. Here are some common commands to verify and manage your instance:
-
Update the package list:
sudo apt update
-
Upgrade the installed packages:
sudo apt upgrade -y
Conclusion
You've successfully launched, connected to, and verified your AWS EC2 instance. This setup can now serve as the foundation for your web applications or development environment. 🌐
Additional Resources
If you have any questions or run into issues, feel free to leave a comment below.
Happy cloud computing! ☁️👩💻👨💻
Top comments (0)