Step-by-Step Guide: Launching and Accessing an EC2 Instance — A Hands-On Tutorial

Sahdev Grover
6 min readJun 21, 2023

--

Welcome to our beginner-friendly guide on how to launch and access EC2 instances in AWS. Whether you’re new to Amazon Web Services (AWS) or just starting your cloud computing journey, this blog post is here to help you.

In this hands-on tutorial, we’ll walk you through the simple steps of creating your own virtual server and connecting to it.

EC2 instances are like virtual computers that you can use to run your applications in the AWS cloud. By the end of this tutorial, you’ll have the knowledge and confidence to launch your own EC2 instance and access it from anywhere.

So, let’s get started and unlock the power of EC2 together!

PREREQUISITES :

AWS ACCOUNT

It is recommended to utilize the free-tier services; otherwise, you will be required to pay for the services based on your usage.

This is the key advantage that AWS offers to its users: paying only for what you use.

Here is a step-by-step guide to launching an EC2 instance via the AWS Management Console:

1. Log in to the AWS Management Console.

2. Navigate to the EC2 service either by searching for “EC2” in the search bar or by selecting it from the services menu.

3. Click on the “Launch Instance” button.

4. Provide a name and tags for your EC2 instance.

5. Choose an Amazon Machine Image (AMI), which is the operating system and software that will run on your instance.

It is recommended to choose the default option that is free-tier eligible.

6. Select an instance type, determining the hardware configuration based on your resource requirements.

It is recommended to keep the default settings, which are free-tier eligible.

7. Configure key pairs. Create your first key pair by giving it a name and selecting the key pair type and private key file format.

Make sure to download and securely store your key pair.

NOTE: If you already have a key pair, you can use an existing one to connect to your instance.

8. Configure the network settings. Create a security group and allow SSH traffic and HTTP traffic from the internet.

Security groups define inbound and outbound rules for network access to your instance.

9. Configure storage. Specify the size and type of storage (EBS volumes) you need for your instance.

It is recommended to use the default settings, which are free-tier eligible.

NOTE: You can get up to 30 GB of free storage in the free tier.

10. Scroll down and click on “Advanced Details.”

11. Again, scroll down to the end of the section where you will find the optional “User Data” section, you can input any scripts or commands required for your instance setup.

#!/bin/bash

# Use this for your user data (script from top to bottom)

# install httpd (Linux 2 version)

yum update -y

yum install -y httpd

systemctl start httpd

systemctl enable httpd

echo “<h1>Hello World from $(hostname -f)</h1>” > /var/www/html/index.html

NOTE: Once done, review your instance details to ensure everything is correct.

12. Specify the number of instances you want to launch in the summary section.

13. Click on the “Launch Instance” button.

14. Once the instance is launched, you’ll see a success message. Scroll down and click on the “View all Instances” button.

15. In the instances list, locate your newly launched instance and wait for it to reach the “running” state with passing status checks.

16. To connect to your instance, select it from the list and click on “Connect.”

17. Follow the instructions to connect to your instance using the preferred method (e.g.EC2 Instance Connect).

18. Once connected, you can start using your EC2 instance as needed.

19. Now that you have connected to your EC2 instance through your operating system, you can execute any Linux command to verify that it is working properly.

Here is an example command you can try:

Instance Management

You have the ability to change the state of an EC2 instance in AWS, such as stopping or terminating it. However, if your workload is currently running on the EC2 instance, it is crucial to avoid termination without creating a backup of your data. Terminating the instance effectively deletes the created instance.

Below are the example of stopping and terminating the desired instance.

1. Stopping an EC2 Instance

2. Terminating an EC2 Instance

EC2 Instance using ssh on Windows

1. Go to SSH client section and copy the command, as shown below

2. Open the Command Prompt or Windows Powershell on your Windows machine and paste the ssh command there.

3. You should now be connected to the EC2 instance using open SSH on your Windows machine, let’s do some commands!

CONCLUSION

We have covered the essential steps to launch and access EC2 instances in AWS. This beginner-friendly guide has provided you with a straightforward tutorial to create your own virtual server and establish a connection to it.

By following these steps, you now have the knowledge and skills to leverage the scalability and flexibility of EC2 for your applications and projects. EC2 instances serve as the foundation of cloud computing, offering a wide range of possibilities for running your workloads in the AWS cloud.

Remember to explore further and continue learning about different EC2 configurations and features. This will help you maximize the potential of AWS cloud services and unlock even more benefits.

Don’t forget to follow me on LinkedIn, where I cover all my content related to the fundamentals of cloud computing and AWS https://www.linkedin.com/in/sahdevgrover

If you have any queries or require assistance, please feel free to reach out. Your feedback is highly appreciated as we continue to explore more things in the world of AWS.

THANK YOU FOR READING MY ARTICLE!

--

--

Sahdev Grover

DevOps Enthusiast | AWS Certified | Terraform Certified | Tech Blogger | Content Writer | Simplifying Iaac & Cloud