๐ How to Launch an EC2 Instance in the New AWS Console
Table of contents
- Step 1: ๐ Log into Your AWS Console
- Step 2: ๐ Search for EC2
- Step 3: ๐ฅ๏ธ Access the Instances Section
- Step 4: โก Launch an Instance
- Step 5: ๐ ๏ธ Configure Your Instance
- Step 5.6: ๐พ Configure Storage
Launching an EC2 instance is the first step towards harnessing the power of cloud computing in AWS! Whether you're deploying a web server, hosting an application, or experimenting with different technologies, AWS EC2 (Elastic Compute Cloud) gives you the flexibility to scale your resources on demand. Here's a step-by-step and easy-to-follow guide to launching your EC2 instance on the latest AWS Console. ๐
Step 1: ๐ Log into Your AWS Console
Open the AWS Console in your browser and log in with your AWS credentials.
Step 2: ๐ Search for EC2
In the search bar at the top, type EC2 and select EC2 Dashboard.
Step 3: ๐ฅ๏ธ Access the Instances Section
On the left side, click on Instances to go to the Instances Dashboard.
Step 4: โก Launch an Instance
In the Instances Dashboard, look at the top right corner for the Launch Instance button. Click it to open the new page where you can configure your instance.
Step 5: ๐ ๏ธ Configure Your Instance
Step 5.1: ๐ท๏ธ Name Your Instance
Give your instance a name, such as demo (or any name you prefer).
Step 5.2: ๐ฅ๏ธ Select an Image for Your Instance
- Choose an Amazon Machine Image (AMI), which determines the operating system for your instance.
Step 5.3: ๐ธ Choose an Instance Type
Select an instance type. Iโll choose t2.micro, which is eligible for the AWS free tier (1 vCPU and 1 GB of RAM).
Step 5.4: ๐ Key Pair Login
Select a key pair. A key pair allows you to SSH into your AWS instance from your local machine.
If you donโt have one, create a new key pair.
Step 5.4.1: ๐ท๏ธ Name Your Key Pair
Name your key pair, e.g., demo-keypair. Choose .pem format if youโre using macOS, or .ppk if on Windows with PuTTY.
Click Create, and AWS will generate a key pair and automatically download the .pem file.
Select your key pair from the list.
Step 5.5: ๐ Configure Network Settings
Step 5.5.1: ๐ VPC Configuration
- For now, leave everything as default, including the VPC.
Step 5.5.2: ๐ Configure Firewall Settings
You can either leave the default firewall settings with SSH access or create a security group with custom inbound and outbound rules.
To skip custom rules, just select SSH and HTTP access.
Step 5.5.2.1: ๐ Create a Security Group
What is a security group?
- A security group acts as a virtual firewall for your instance to control inbound and outbound traffic. It is used to define which IP addresses can communicate with your EC2 instance over specific ports like HTTP, SSH, etc.
Go to Security Groups in the EC2 Dashboard and create a new one, e.g., demo-test.
Inbound Rules:
Rule 1: I want to access my instance via SSH, so Iโll provide inbound SSH access from everyone. Select the type as SSH, and for source, select 0.0.0.0/0 (anyone can access via SSH).
Rule 2: Rule 2: I want to access the instance from the internet. To configure this as a server, select the type as HTTP and the source as 0.0.0.0/0 (anyone can access via HTTP).
Outbound Rules:
- Rule 1: I want to give the instance internet access because we will update the instance and download httpd for hosting the server. Select the type as All Traffic and the source as 0.0.0.0/0 (anyone can access anything on the internet).
Now create the security group: After you create the security group, go back to the EC2 instance launch page.
Select the Existing Security Group:
Click on Select Existing Security Groups.
Choose the demo-test security group you just created.
If it doesn't show up immediately, click the refresh button next to the list of security groups. Donโt refresh the entire page; just click the circle next to the security group list.
Step 5.6: ๐พ Configure Storage
Leave the storage settings as default. It will create an EBS volume and attach it to your instance.
- If you want more storage, you can increase it, but I recommend staying within the free tier (30 GB for total EBS volume).
Step 5.7: ๐ Configure User Data
What is user data?
User data is a script that runs when the instance starts, and it helps automate the setup.
Click on Advanced Settings, go to User Data, and paste the following script:
- Script:
#!/bin/bash
sudo yum -y update
sudo yum -y install httpd
sudo systemctl start httpd
sudo systemctl enable httpd
echo "<h1>My instance is running</h1>" | sudo tee /var/www/html/index.html
sudo systemctl restart httpd
Step 6: โณ Wait for the Instance to Initialize
Go to the Instances Dashboard and wait for the instance to reach the running state.
Youโll see the instance initializing.
Step 7: ๐ Check the Instanceโs Public IP
Click on the instance, and in the lower section, find the Public IP.
Copy the Public IP and paste it into your browser:
http://<public_ip_address>
Voila! ๐ Youโll see a page displaying: โMy instance is runningโ.
Conclusion ๐
Congratulations! You've successfully launched an EC2 instance in AWS. ๐ Now you can use your instance for development, testing, or even as a public web server. The AWS cloud offers incredible flexibility, so feel free to explore more options, adjust configurations, and scale as your needs grow.