Get started with Amazon EC2

Use this tutorial to get started with Amazon Elastic Compute Cloud (Amazon EC2). You'll learn how to launch and connect to an EC2 instance. An instance is a virtual server in the AWS Cloud. With Amazon EC2, you can set up and configure the operating system and applications that run on your instance.

Overview

The following diagram shows the key components that you'll use in this tutorial:

An instance with a security group, key pair, and EBS root volume.

Cost for this tutorial

When you sign up for AWS, you can get started with Amazon EC2 using the AWS Free Tier . If you created your AWS account less than 12 months ago, and have not already exceeded the Free Tier benefits for Amazon EC2, it won't cost you anything to complete this tutorial, because we help you select options that are within the Free Tier benefits. Otherwise, you'll incur the standard Amazon EC2 usage fees from the time that you launch the instance until you terminate the instance (which is the final task of this tutorial), even if it remains idle.

For instructions to determine whether you are eligible for the Free Tier, see Track your Free Tier usage for Amazon EC2.

Tasks

Step 1: Launch an instance

You can launch an EC2 instance using the AWS Management Console as described in the following procedure. This tutorial is intended to help you quickly launch your first instance, so it doesn't cover all possible options.

To launch an instance
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ .
  2. In the navigation bar at the top of the screen, we display the current AWS Region — for example, Ohio. You can use the selected Region, or optionally select a Region that is closer to you.
  3. From the EC2 console dashboard, in the Launch instance pane, choose Launch instance.
  4. Under Name and tags, for Name, enter a descriptive name for your instance.
  5. Under Application and OS Images (Amazon Machine Image), do the following:
    1. Choose Quick Start, and then choose the operating system (OS) for your instance. For your first Linux instance, we recommend that you choose Amazon Linux.
    2. From Amazon Machine Image (AMI), select an AMI that is marked Free Tier eligible .
    Warning

    If you choose Proceed without a key pair (Not recommended), you won't be able to connect to your instance using the methods described in this tutorial.

    Step 2: Connect to your instance

    The procedure that you use depends on the operating system of the instance. If you can't connect to your instance, see Troubleshoot issues connecting to your Amazon EC2 Linux instance for assistance.

    You can connect to your Linux instance using any SSH client. If you are running Windows on your computer, open a terminal and run the ssh command to verify that you have an SSH client installed. If the command is not found, install OpenSSH for Windows .

    To connect to your instance using SSH
    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ .
    2. In the navigation pane, choose Instances.
    3. Select the instance and then choose Connect.
    4. On the Connect to instance page, choose the SSH client tab.
    5. (Optional) If you created a key pair when you launched the instance and downloaded the private key (.pem file) to a computer running Linux or macOS, run the example chmod command to set the permissions for your private key.
    6. Copy the example SSH command. The following is an example, where key-pair-name .pem is the name of your private key file, ec2-user is the username associated with the image, and the string after the @ symbol is the public DNS name of the instance.
    ssh -i key-pair-name.pem ec2-user@ec2-198-51-100-1.us-east-2.compute.amazonaws.com
    The authenticity of host 'ec2-198-51-100-1.us-east-2.compute.amazonaws.com (198-51-100-1)' can't be established. ECDSA key fingerprint is l4UB/neBad9tvkgJf1QZWxheQmR59WgrgzEimCG6kZY. Are you sure you want to continue connecting (yes/no)?
    Warning: Permanently added 'ec2-198-51-100-1.us-east-2.compute.amazonaws.com' (ECDSA) to the list of known hosts.

    To connect to a Windows instance using RDP, you must retrieve the initial administrator password and then enter this password when you connect to your instance. It takes a few minutes after instance launch before this password is available.

    The default username for the Administrator account depends on the language of the operating system (OS) contained in the AMI. To ascertain the correct username, identify the language of your AMI's OS, and then choose the corresponding username. For example, for an English OS, the username is Administrator , for a French OS it's Administrateur , and for a Portuguese OS it's Administrador . If a language version of the OS does not have a username in the same language, choose the username Administrator (Other) . For more information, see Localized Names for Administrator Account in Windows in the Microsoft TechNet Wiki.

    To retrieve the initial administrator password
    1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ .
    2. In the navigation pane, choose Instances.
    3. Select the instance and then choose Connect.
    4. On the Connect to instance page, choose the RDP client tab.
    5. For Username, choose the default username for the Administrator account. The username you choose must match the language of the operating system (OS) contained in the AMI that you used to launch your instance. If there is no username in the same language as your OS, choose Administrator (Other).
    6. Choose Get password.
    7. On the Get Windows password page, do the following:
      1. Choose Upload private key file and navigate to the private key ( .pem ) file that you specified when you launched the instance. Select the file and choose Open to copy the entire contents of the file to this window.
      2. Choose Decrypt password. The Get Windows password page closes, and the default administrator password for the instance appears under Password, replacing the Get password link shown previously.
      3. Copy the password and save it in a safe place. This password is required to connect to the instance.

      The following procedure uses the Remote Desktop Connection client for Windows (MSTSC). If you're using a different RDP client, download the RDP file and then see the documentation for the RDP client for the steps to establish the RDP connection.

      To connect to a Windows instance using an RDP client
      1. On the Connect to instance page, choose Download remote desktop file. When the file download is finished, choose Cancel to return to the Instances page. The RDP file is downloaded to your Downloads folder.
      2. Run mstsc.exe to open the RDP client.
      3. Expand Show options, choose Open, and select the .rdp file from your Downloads folder.
      4. By default, Computer is the public IPv4 DNS name of the instance and User name is the administrator account. To connect to the instance using IPv6 instead, replace the public IPv4 DNS name of the instance with its IPv6 address. Review the default settings and change them as needed.
      5. Choose Connect. If you receive a warning that the publisher of the remote connection is unknown, choose Connect to continue.
      6. Enter the password that you saved previously, and then choose OK.
      7. Due to the nature of self-signed certificates, you might get a warning that the security certificate could not be authenticated. Do one of the following:
        • If you trust the certificate, choose Yes to connect to your instance.
        • [Windows] Before you proceed, compare the thumbprint of the certificate with the value in the system log to confirm the identity of the remote computer. Choose View certificate and then choose Thumbprint from the Details tab. Compare this value to the value of RDPCERTIFICATE-THUMBPRINT in Actions, Monitor and troubleshoot, Get system log.
        • [Mac OS X] Before you proceed, compare the fingerprint of the certificate with the value in the system log to confirm the identity of the remote computer. Choose Show Certificate, expand Details, and choose SHA1 Fingerprints. Compare this value to the value of RDPCERTIFICATE-THUMBPRINT in Actions, Monitor and troubleshoot, Get system log.
      8. If the RDP connection is successful, the RDP client displays the Windows login screen and then the Windows desktop. If you receive an error message instead, see Remote Desktop can't connect to the remote computer. When you are finished with the RDP connection, you can close the RDP client.

      Step 3: Clean up your instance

      After you've finished with the instance that you created for this tutorial, you should clean up by terminating the instance. If you want to do more with this instance before you clean up, see Next steps.

      Important

      Terminating an instance effectively deletes it; you can't reconnect to an instance after you've terminated it.

      You'll stop incurring charges for that instance or usage that counts against your Free Tier limits as soon as the instance status changes to shutting down or terminated . To keep your instance for later, but not incur charges or usage that counts against your Free Tier limits , you can stop the instance now and then start it again later. For more information, see Stop and start Amazon EC2 instances.

      To terminate your instance
      1. In the navigation pane, choose Instances. In the list of instances, select the instance.
      2. Choose Instance state, Terminate instance.
      3. Choose Terminate when 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 automatically deleted. You cannot remove the terminated instance from the console display yourself.

      Next steps

      After you start your instance, you might want to explore the following next steps:

      • Learn how to track your Amazon EC2 Free Tier usage using the console. For more information, see Track your Free Tier usage for Amazon EC2.
      • Configure a CloudWatch alarm to notify you if your usage exceeds the Free Tier. For more information, see Tracking your AWS Free Tier usage in the AWS Billing User Guide.
      • Add an EBS volume. For more information, see Create an Amazon EBS volume in the Amazon EBS User Guide.
      • Learn how to remotely manage your EC2 instance using the Run command. For more information, see AWS Systems Manager Run Command in the AWS Systems Manager User Guide.
      • Learn about instance purchasing options. For more information, see Amazon EC2 billing and purchasing options.
      • Get advice about instance types. For more information, see Get recommendations from EC2 instance type finder.