How to Launch EC2 Instance in AWS
Launching an EC2 (Elastic Compute Cloud) instance in AWS is a fundamental step in building scalable cloud applications. EC2 provides resizable compute capacity, making it easier for developers to run and manage applications efficiently. This guide outlines the step-by-step process to launch an EC2 instance in AWS.
Prerequisites
Before starting, ensure you have the following:
- An active AWS account
- Basic understanding of AWS services
- Installed and configured AWS CLI (optional but helpful)
Step 1: Log in to AWS Management Console
- Go to the AWS Management Console.
- Sign in using your AWS account credentials.
Step 2: Navigate to the EC2 Dashboard
- In the AWS Management Console, search for EC2 in the search bar.
- Click on EC2 under Services to open the EC2 Dashboard.
Step 3: Choose “Launch Instance”
- On the EC2 Dashboard, click on the Launch Instance button.
- Enter a suitable name for your instance under Name and tags.
Step 4: Select an Amazon Machine Image (AMI)
- AMI acts as the base image for your instance. Choose one based on your operating system preference.
- Common choices include:
- Amazon Linux 2023 (Free Tier eligible)
- Ubuntu Server
- Windows Server
- Click Select next to your chosen AMI.
Step 5: Choose an Instance Type
- Select an instance type that fits your workload requirements.
- For basic usage, select t2.micro (Free Tier eligible).
- Click Next: Configure Instance Details.
Step 6: Configure Instance Details
- Set the number of instances you want to launch.
- Network settings can typically be left at their default values for basic configurations.
- Enable Auto-assign Public IP to access the instance over the internet.
- Click Next: Add Storage.
Step 7: Add Storage
- By default, the recommended storage volume is 8 GB (for Free Tier).
- Increase storage if your application requires more capacity.
- Click Next: Add Tags.
Step 8: Add Tags (Optional but Recommended)
- Tags are key-value pairs that help identify your resources.
- For example:
Key: Name
,Value: MyWebServer
. - Click Next: Configure Security Group.
Step 9: Configure Security Group
- Security groups act as virtual firewalls for your instance.
- Click Create a new security group.
- Add rules for inbound traffic, such as:
- HTTP (port 80) for web servers
- SSH (port 22) for remote access
- Click Review and Launch.
Step 10: Review and Launch
- Review all configurations to ensure they meet your requirements.
- Click Launch.
- When prompted, select an existing key pair or create a new one. Download the
.pem
file and keep it safe. This file is required for SSH access.
Step 11: Access Your EC2 Instance
- Go back to the EC2 Dashboard.
- Under Instances, select your running instance.
- Copy the Public IPv4 address.
- Open your terminal and connect using the following command:
ssh -i /path/to/your/key.pem ec2-user@your-public-ip
Step 12: Verify Instance Functionality
- Once connected, you can install packages, configure services, and deploy applications.
- Use commands like:
sudo yum update -y sudo apt update && sudo apt upgrade -y
Step 13: Setting Up Elastic IP (Optional but Recommended)
To ensure your instance retains a fixed IP address, consider assigning an Elastic IP.
- Go to the Elastic IPs section in the EC2 dashboard.
- Click Allocate Elastic IP address.
- Associate the Elastic IP with your instance.
Step 14: Terminating an EC2 Instance (If No Longer Needed)
- On the EC2 Dashboard, select the instance you want to terminate.
- Click Instance State -> Terminate Instance.
Conclusion
By following these steps, you can successfully launch and manage an EC2 instance in AWS. Whether you are developing, testing, or hosting web applications, AWS EC2 offers a flexible and scalable solution for your cloud computing needs. Always remember to secure your instance, configure backups, and monitor resource usage for optimal performance.