AWS Tutorial | Compute | EC2 | Launching and Terminating an Instance

What is Amazon EC2?

  • Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud.
  • Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.
  • You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage.
  • Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic.

Features of Amazon EC2


Amazon EC2 provides the following features:

  • Virtual computing environments, known as instances. 
  • Various configurations of CPU, memory, storage, and networking capacity for your instances, known as instance types.
  • Preconfigured templates for instances, known as Amazon Machine Images (AMIs)
  • Multiple physical locations for your resources, such as instances and Amazon EBS volumes, known as Regions and Availability Zones.
  • Secure login information for instances using key pairs.
  • Persistent storage volumes for your data using Amazon Elastic Block Store (Amazon EBS), known as Amazon EBS volumes
  • A firewall that enables you to specify the protocols, ports, and source IP ranges that can reach your instances using security groups
  • Static IPv4 addresses for dynamic cloud computing, known as Elastic IP addresses
  • Metadata, known as tags, that you can create and assign to your Amazon EC2 resources

Lets get started with EC2 - Launch an EC2 instance



1. Open the Amazon EC2 console at



2. From the console dashboard, choose Launch Instance. Or go to Running Instances and then Launch Instances.



3. The Choose an Amazon Machine Image (AMI)page displays a list of basic configurations, called Amazon Machine Images (AMIs), that serve as templates for your instance. Select an HVM version of Amazon Linux 2. Notice that these AMIs are marked “Free tier eligible.”


4. On the Choose an Instance Type page, you can select the hardware configuration of your instance. Select the micro type, which is selected by default. Notice that this instance type is eligible for the free tier.


5. Choose Review and Launch to let the wizard complete the other configuration settings for you. or move step by step.



6. On the Review Instance Launch page, choose Launch.



7. On the Review Instance Launch page, under Security Groups, you’ll see that the wizard created and selected a security group for you. You can use this security group, or alternatively you can select the security group that you created when getting set up using the following steps:

  • Choose Edit security groups.
  • On the Configure Security Group page, ensure that Select an existing security group is selected.
  • Select your security group from the list of existing security groups, and then choose Review and Launch.


8. When prompted for a key pair, select Choose an existing key pair, then select the key pair that you created when getting set up.

Alternatively, you can create a new key pair. Select Create a new key pair, enter a name for the key pair, and then choose Download Key Pair. This is the only chance for you to save the private key file, so be sure to download it. Save the private key file in a safe place. You’ll need to provide the name of your key pair when you launch an instance and the corresponding private key each time you connect to the instance.


9. A confirmation page lets you know that your instance is launching. Choose View Instances to close the confirmation page and return to the console.


10. On the Instances screen, you can view the status of the launch. It takes a short time for an instance to launch. When you launch an instance, its initial state is pending. After the instance starts, its state changes to running and it receives a public DNS name. (If the Public DNS (IPv4) column is hidden, choose Show/Hide Columns (the gear-shaped icon) in the top right corner of the page and then select Public DNS (IPv4).)


11. It can take a few minutes for the instance to be ready so that you can connect to it. Check that your instance has passed its status checks; you can view this information in the Status Checks

How to Create a key pair before launching an EC2 Instance

  1. Open the Amazon EC2 console at
  2. In the navigation pane, choose Key Pairs.
  3. Choose Create key pair.
  4. For Name, enter a descriptive name for the key pair. Amazon EC2 associates the public key with the name that you specify as the key name. A key name can include up to 255 ASCII characters. It can’t include leading or trailing spaces.
  5. For File format, choose the format in which to save the private key. To save the private key in a format that can be used with OpenSSH, choose pem. To save the private key in a format that can be used with PuTTY, choose ppk.
  6. Choose Create key pair.

How to Create a security group

  1. Open the Amazon EC2 console at
  2. From the navigation bar, select a Region for the security group. Security groups are specific to a Region, so you should select the same Region in which you created your key pair.
  3. In the navigation pane, choose Security Groups.
  4. Choose Create security group.
  5. In the Basic detailssection, do the following:
    1. Enter a name for the new security group and a description. Use a name that is easy for you to remember, such as your user name, followed by _SG_, plus the Region name. For example, me_SG_uswest2.
    2. In the VPClist, select your default VPC for the Region.
  6. In the Inbound rulessection, create the following rules (choose Add rule for each new rule):
    • Choose HTTPfrom the Type list, and make sure that Source is set to Anywhere (0.0.0/0).
    • Choose HTTPSfrom the Type list, and make sure that Source is set to Anywhere (0.0.0/0).
    • Choose SSHfrom the Type In the Source box, choose My IP to automatically populate the field with the public IPv4 address of your local computer. Alternatively, choose Custom and specify the public IPv4 address of your computer or network in CIDR notation. To specify an individual IP address in CIDR notation, add the routing suffix /32, for example, If your company allocates addresses from a range, specify the entire range, such as

How to Terminate an Instance

  1. In the navigation pane, choose Instances. In the list of instances, select the instance.
  2. Choose ActionsInstance StateTerminate.
  3. Choose Yes, Terminatewhen prompted for confirmation.

Amazon EC2 shuts down and terminates your instance. After your instance is terminated, it remains visible on the console for a short while, and then the entry is deleted.


I have been learning Software Testing since 12 years, have worked in multiple roles in Investment Banking, Aviation and Digital areas. Still exploring and learning, current article is also a part of this acquaintance. In case you would like to keep in touch, drop me a note at

View all posts by Rahul →