How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners)

Amazon EC2 (Elastic Compute Cloud) is one of the most popular services in AWS, allowing you to launch and manage virtual machines in the cloud. In this guide, we’ll walk through creating a Demo EC2 instance using the Amazon Linux AMI and a t2.micro fre…


This content originally appeared on DEV Community and was authored by ibrahim Bio Abubakar

Amazon EC2 (Elastic Compute Cloud) is one of the most popular services in AWS, allowing you to launch and manage virtual machines in the cloud. In this guide, we’ll walk through creating a Demo EC2 instance using the Amazon Linux AMI and a t2.micro free-tier instance type. We’ll also add a simple user data script to run on startup.

Prerequisites

  • An AWS account
  • Basic familiarity with AWS Management Console

Step 1: Log in to AWS Management Console

  1. Head over to AWS Console.
  2. From the Services menu, search for EC2 and click on it.

Image 2

Step 2: Launch an Instance

  1. Click Launch instance.

Image 2

  1. Give your instance a name: Demo EC2.

Image 3

Step 3: Choose Amazon Machine Image (AMI)

  1. In the Application and OS Images section, choose:
  • Amazon Linux (Free Tier eligible).

Image 4

⚡ Step 4: Select Instance Type

  1. From the Instance type dropdown, select:
  • t2.micro (Free Tier eligible).

Image 5

Step 5: Configure User Data (Startup Script)

  1. Scroll down to Advanced details.
  2. In the User data section, paste the following script:
   #!/bin/bash
   echo "Hurray!!! We got this working" > /home/ec2-user/startup.txt

Image 6

This script will create a file named startup.txt with the message inside.

Step 6: Configure Key Pair

  1. Either select an existing key pair or create a new one.
  2. This will allow you to SSH into your instance later.

Image 7

Step 7: Configure Network Settings

  1. Choose default VPC and subnet (unless you want custom networking).
  2. Allow SSH traffic from your IP.
  3. Allow HTTP traffic from the internet.

Image 8

Step 8: Launch the Instance

  1. Review all settings.

Image 9

  1. Click Launch instance.

Your Demo EC2 instance will now spin up in the cloud!

Image 10

Step 9: Verify User Data Script

  1. Once the instance is running, select connect for EC2 Instance Connect.

Image 11

  1. Ensure the Connection type is set to Connect using a Public IP, Puplic IPv4 address is selected and the Username is ec2-user; then select Connect.

Image 12

We have now successfully connected to the Amazon Linux 2023 machine:

  1. Run:
   cat /home/ec2-user/startup.txt

  1. You should see:
   Hurray!!! We got this working

Conclusion

In just a few steps, you’ve launched your first Amazon EC2 instance using Amazon Linux on a t2.micro free-tier machine. With the user data script, we confirmed automation works right at startup.

Next steps: Try customizing the user data script to install software packages, run web servers, or deploy applications automatically.


This content originally appeared on DEV Community and was authored by ibrahim Bio Abubakar


Print Share Comment Cite Upload Translate Updates
APA

ibrahim Bio Abubakar | Sciencx (2025-09-25T14:55:54+00:00) How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners). Retrieved from https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/

MLA
" » How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners)." ibrahim Bio Abubakar | Sciencx - Thursday September 25, 2025, https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/
HARVARD
ibrahim Bio Abubakar | Sciencx Thursday September 25, 2025 » How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners)., viewed ,<https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/>
VANCOUVER
ibrahim Bio Abubakar | Sciencx - » How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/
CHICAGO
" » How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners)." ibrahim Bio Abubakar | Sciencx - Accessed . https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/
IEEE
" » How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners)." ibrahim Bio Abubakar | Sciencx [Online]. Available: https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/. [Accessed: ]
rf:citation
» How to Create an EC2 VM in AWS (Step-by-Step Guide for Beginners) | ibrahim Bio Abubakar | Sciencx | https://www.scien.cx/2025/09/25/how-to-create-an-ec2-vm-in-aws-step-by-step-guide-for-beginners/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.