| Did this page help you? Yes No Tell us about it... |
This section describes how to run an instance.
You can either leverage the Free Usage Tier to launch and use a free Amazon EC2 Micro Instance for 12 months, or you can launch a regular instance (not within the Free Usage Tier). For more information about the Free Usage Tier, go to the AWS Free Usage Tier product page and Getting Started with AWS Free Usage Tier.
If you want to launch an instance that is not within the Free Usage Tier, you will incur the standard Amazon EC2 usage fees for the instance. For more information about Amazon EC2 usage rates, go to the Amazon EC2 product page.
![]() | Important |
|---|---|
If you launch an instance not within the Free Usage Tier, you are billed once you launch the instance and charged for the time that the instance is running even if it remains idle. |
To launch an instance
Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
From the Amazon EC2 console dashboard, click Launch Instance.
The Create a New Instance page provides two ways to launch an instance:
The Classic Wizard offers you more granular control and advanced settings for configuring the type of instance you want to launch. For this procedure, we'll use the Classic Wizard.
The Quick Launch Wizard simplifies the process for you and automatically configures many selections for you to get you started quickly with an instance. If you are just trying Amazon EC2, see Getting Started with Amazon EC2 in the Amazon Elastic Compute Cloud Getting Started Guide to get started.
Click Classic Wizard, and then click Continue.
The Quick Start tab of the wizard displays a list of basic configurations called Amazon Machine Images (AMIs) which you can choose from to launch an instance. An Amazon Machine Image (AMI) contains all the information needed to create a new instance of a server. For example, an AMI might contain all the software to act as a web server (e.g., Linux, Apache, and your website). To keep things simple, AWS marks the AMIs that are available in the Free Usage Tier with a star.
Select the AMI that you want to use, and click Continue.
![]() | Note |
|---|---|
We recommend launching a basic AMI for this tutorial, but you can launch any AMI. |
On the Instance Details page, confirm the following settings and click Continue.
The Number of Instances is set to 1.
The Availability Zone is set to No Preference. We
recommend that you keep this setting.
The Instance Type is set to Micro
(t1.micro).
The second Instance Details page is displayed with advanced instance options.
Click Continue to accept the default settings for the advanced options.
The third Instance Details page displays. Here you can specify tags for the instance (for more information, see Using Tags).
Click Continue to accept the default tag settings.
The Create Key Pair page is displayed.
Under Choose a Key Pair, you can choose from any existing key pairs that you have created or create a new one. For this example, we’ll create a key pair:
![]() | Important |
|---|---|
Do not select the None option. If you launch an instance without a key pair, you will not be able to connect to your instance. This option is used when you are creating your own AMI and do not need to connect to the instance. |
Click Create new Key Pair.
Type a name for your key pair and then click Download. You will need the contents of the private key to connect to your instance once it is launched. Amazon Web Services does not keep the private portion of key pairs.
Save the private key in a safe place on your system. Note the location because you'll need the key to connect to the instance.
On the Configure Firewall page, the wizard automatically makes a security group selection for you.
A security group defines firewall rules for your instances. These rules specify which incoming network traffic will be delivered to your instance. All other traffic is ignored.
If you're new to Amazon EC2 and haven't set up any security groups yet, AWS defines a default security group for you. If you use an Amazon Machine Image on the Quick Start tab, the name and description for the group is quick-start-x where x is a number associated with your quick-start group. The first security group you create using the Quick Start tab is named quick-start-1. You can change the name and description. For an Amazon Linux instance, you connect through SSH on port 22. The quick-start-x security group automatically allows SSH traffic on port 22. For a Windows instance, you connect through Remote Desktop Protocol (RDP) and the security group automatically allows RDP traffic on port 3389.
If you have used Amazon EC2 before, the wizard looks for an existing security group for the type of instance you’re creating.
![]() | Caution |
|---|---|
The quick-start-x security group enables all IP addresses to access your instance over the specified ports (e.g., SSH for Linux/UNIX or RDP for Windows). This is acceptable for the short exercise in this tutorial, but it's unsafe for production environments. In production, you'll authorize only a specific IP address or range of addresses to access your instance. |
![]() | Note |
|---|---|
After an instance is running, you can't change which security groups it belongs to, but you can add and remove rules. |
Click Continue to review your settings.
Click Launch to begin launching your instance.
To launch an instance
Use the ec2-run-instances command.
PROMPT>ec2-run-instances ami-3ac33653 -k gsg-keypair
Amazon EC2 returns output similar to the following example.
RESERVATION r-f25e6f9a 111122223333 default INSTANCE i-85b435ee ami-3ac33653 pending gsg-keypair 0 m1.small 2010-03-30T08:01:36+0000 us-east-1a aki-407d9529 monitoring-disabled ebs
Look for the instance ID in the second field and write it down.
You use it to manipulate this instance (including terminating it when you are finished).
It takes a few minutes for the instance to launch.
The following command displays the launch status of the instance.
PROMPT>ec2-describe-instancesRESERVATION r-f25e6f9a 111122223333 default INSTANCE i-85b435ee ami-3ac33653 ec2-67-202-28-13.compute-1.amazonaws.com domU-12-31-39-00-78-93.compute-1.internal running gsg-keypair 0 m1.small 2010-03-30T08:01:36+0000 us-east-1a aki-407d9529 monitoring-disabled 67.202.28.13 10.254.127.97 ebs BLOCKDEVICE /dev/sda1 vol-02a2a46b 2010-03-30T08:01:44.000Zi-85b435ee
![]() | Important |
|---|---|
After launching an instance, you are billed hourly for running time. When you are finished, make sure to terminate any instances that you started. |
When the instance state in the field just before the key pair name reads "running," the instance has started booting. There might be a short time before it is accessible over the network, however. The first DNS name is your instance's external DNS name, i.e. the one that can be used to contact it from the Internet. The second DNS name is your instance's local DNS name, and is only contactable by other instances within the Amazon EC2 network. The DNS names of your instances are different than those shown in the preceding example and you should use yours instead. The examples in this guide use the public DNS name.
If the instance's state immediately goes to "terminated" instead of "running," you can get information about why the instance didn't launch. For more information, see What to Do If an Instance Immediately Terminates.
To launch an instance
Construct the following Query request.
https://ec2.amazonaws.com/ ?Action=RunInstances &ImageId=ami-3ac33653 &MaxCount=1 &MinCount=1 &KeyName=gsg-keypair &Placement.AvailabilityZone=us-east-1a &...auth parameters...
Following is an example response.
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
<reservationId>r-47a5402e</reservationId>
<ownerId>111122223333</ownerId>
<groupSet>
<item>
<groupId>default</groupId>
</item>
</groupSet>
<instancesSet>
<item>
<instanceId>i-2ba64342</instanceId>
<imageId>ami-3ac33653</imageId>
<instanceState>
<code>0</code>
<name>pending</name>
</instanceState>
<privateDnsName></privateDnsName>
<dnsName></dnsName>
<keyName>gsg-keypair</keyName>
<amiLaunchIndex>0</amiLaunchIndex>
<instanceType>m1.small</instanceType>
<launchTime>2007-08-07T11:51:50.000Z</launchTime>
<placement>
<availabilityZone>us-east-1a</availabilityZone>
</placement>
<monitoring>
<enabled>false</enabled>
</monitoring>
</item>
</instancesSet>
</RunInstancesResponse>To view the status of a launched instance
Construct the following Query request.
https://ec2.amazonaws.com/ ?Action=DescribeInstances &InstanceId=i-2ba64342 &...auth parameters...
Following is an example response.
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
<reservationId>r-47a5402e</reservationId>
<ownerId>111122223333</ownerId>
<groupSet>
<item>
<groupId>default</groupId>
</item>
</groupSet>
<instancesSet>
<item>
<instanceId>i-2ba64342</instanceId>
<imageId>ami-3ac33653</imageId>
<instanceState>
<code>16</code>
<name>running</name>
</instanceState>
<privateDnsName></privateDnsName>
<dnsName></dnsName>
<keyName>gsg-keypair</keyName>
<amiLaunchIndex>0</amiLaunchIndex>
<instanceType>m1.small</instanceType>
<launchTime>2007-08-07T11:51:50.000Z</launchTime>
<placement>
<availabilityZone>us-east-1a</availabilityZone>
</placement>
<monitoring>
<enabled>false</enabled>
</monitoring>
</item>
</instancesSet>
</DescribeInstancesResponse>If the instance's state immediately goes to "terminated" instead of "running", you can get information about why the instance didn't launch. For more information, see What to Do If an Instance Immediately Terminates.