๐Ÿš€ How to Launch an EC2 Instance in the New AWS Console

ยท

5 min read

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.
  1. Go to Security Groups in the EC2 Dashboard and create a new one, e.g., demo-test.

  2. 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).

  3. 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).
  4. Now create the security group: After you create the security group, go back to the EC2 instance launch page.

  5. 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.

ย