How to launch Amazon EC2 Linux Instance

Amazon EC2 is the service for providing the computing capacity in AWS. With the help of Amazon EC2 you can launch the virtual servers based on your need and you can configure the networking and storage aspects of it. Auto scaling feature in Amazon EC2 helps you to scale up and down your computing needs based on the changing traffic to your instances.

Prerequisites

Activate your AWS account

You have to activate your AWS account to use the Amazon EC2 service.

  • Open https://aws.amazon.com/ and then choose Create an AWS Account.
  • Follow the online instructions to complete the signup.

After activating your AWS account, login to AWS management console.

Create Amazon EC2 key pair

Have your Amazon EC2 key pair ready for connecting to instance after launching it. You can refer the post Creating Amazon EC2 key pair for detailed steps.

Launch an Amazon EC2 Instance

You can launch the EC2 instance using the AWS management console as described in below steps.

  • Access the EC2 management console using the Services menu in the top left corner.

  • In the top right corner you can select the region of your choice. For this example, I chose EU (Frankfurt).

  • After choosing the region, Select Launch Instance in the EC2 Dashboard.
  • In the next page, you can choose the Amazon Machine Image (AMI) of your choice to launch the instance.
  • You have options to select from the AMIs provided by AWS, AWS marketplace, community AMIs or you can have use one of your own AMIs. For this example, choose Ubuntu server AMI provided by AWS which is also free tier eligible.

  • Once you have selected the AMI, you will have option to choose the instance type. AWS provides instance types with varying combinations of CPU, memory, storage, and networking capacity to help you choose based on your computing needs.
  • Select the general purpose t2.micro instance type for this example. This instance type is eligible for free tier as well.

  • Choose Next: Configure Instance Details. Leave the default configuration settings as it is for this example. Choose Next: Add Storage.
  • By default root volume of size 8 GB will be attached to your instance. You can add additional EBS (Elastic Block Storage) volumes based on your need. For this example, leave the storage settings as it is and choose Next: Add Tags.

  • You can add tags for your EC2 instance. Choose click to add a Name tag. For the Key Name, give the Value as my-first-ec2-instance. Choose Next: Configure Security Group.

  • In the security groups configuration, you can either create a new security group or select from the existing groups. For this example, choose Create a new security group. Name it as my-ec2-SG. You can give the give the Description to your security group as well.
  • By default, you will have the rule enabled to allow SSH access from all IP addresses. Leave the rule as it is and choose Review and Launch.

Note:  The rule to allow SSH access from all IP addresses is meant for learning purpose only. In production environments, you must not follow this open to all policy.

  • After reviewing the configuration details for your instance, choose Launch.
  • You will be asked to select the key pair to associate it with your instance. Assuming that you have completed the actions mentioned in the prerequisites for this example, select Choose an existing key pair option.

  • Choose Launch Instances. Now you have launched the EC2 Linux instance.
  • In the EC2 Dashboard, check the Instance state. It will be in pending status.
  • After the Instance state changes to running, you can connect to it.

Connect to your Instance

You can use the PuTTY client to connect to your EC2 Linux instance.

  • Get the PuTTY client from here.
  • Start the PuTTY client. For Host Name, enter the Public DNS (IPv4) of your Instance.
  • Give the name for the Session as my-ec2-client.

  • Now in the Category pane, select Auth under SSH. In the Private key file for authentication, choose your private key file that you have associated with your instance during its launch.

  • Choose Open. Now the PuTTY client will display a Security Alert. Select Yes to proceed.

Note: To get the Public DNS of your Instance, go to the EC2 console and choose Instances in the left navigation pane. Select the Instance that you have launched. You can see the details of Public DNS for the instance under the Description tab.

  • Now the PuTTY will prompt to enter your username. Type ubuntu and hit Enter.

  • You should be able to login successfully to your EC2 Linux instance.

Clean up your EC2 Instance

After you have completed the work with your instance, it’s a best practice to either shut down or terminate your EC2 resource so that you will stop incurring charges.

Terminate your Instance

  • Go to the EC2 console. Choose Instances in the left navigation pane.
  • Select the instance that you have launched for this example.
  • Choose Actions >> Instance State >> Terminate.

  • You will get a Dialog box to confirm your selection. Choose Yes, Terminate.
  • Now the instance state will change to shutting-down and then to terminated.

Conclusion

In this tutorial, you have launched Amazon EC2 Linux instance and connected to it using PuTTY client. Finally you have cleaned up your EC2 instance by terminating it.

So what’s next? Explore further deep in to the Amazon EC2 service and learn how to configure the Elastic Block Storage volumes, Elastic load balancing, Network and Security for your instances.

If you have any questions or concerns, please post it in the comments section. Thank you!

About Vignesh M

Java developer , AWS Certified Solutions Architect Associate and Cloud technology enthusiast. Currently working for Dxc technology. He believes that knowledge increases by sharing not by saving.

Leave a Reply

Your email address will not be published. Required fields are marked *