Amazon Elastic Compute Cloud: Getting Started Guide API Version 2012-12-01
Amazon Elastic Compute Cloud: Getting Started Guide API Version 2012-12-01
Amazon Elastic Compute Cloud: Getting Started Guide API Version 2012-12-01
Getting Started ....................................................................................................................................... 1 Where Do I Go from Here? ................................................................................................................... 11 Document History ................................................................................................................................. 16 Please Provide Feedback ..................................................................................................................... 17
Tip
This tutorial has you launch and connect to an Amazon EC2 Linux instance. If you'd prefer to launch and connect to an Amazon EC2 Windows instance, see this tutorial: Getting Started with Amazon EC2 Windows Instances. For more information about Amazon EC2, see the Amazon EC2 product page.
Step 2: Launch an Amazon EC2 Launch an Amazon Linux instance, which is a virtual server in the Instance (p. 2) cloud. Step 3: Connect to Your Instance (p. 6) Step 4: Explore Your Instance (p. 7) Connect to your instance.
Create an Amazon EC2 volume, attach it to your instance, and use Linux commands on your instance to make the volume available for use. Terminate your instance and delete the volume that you created.
Amazon Elastic Compute Cloud Getting Started Guide Step 1: Sign Up for Amazon EC2
To launch an instance
1. Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. Use the email address and password that you specified when signing up for AWS. From the navigation bar, select the region for the instance. For this tutorial, you can use the default region. Otherwise, this choice is important because some EC2 resources can be shared between regions, while others can't. For example, if you'd like to connect your instance to an existing EBS volume, you must launch the instance in the same region as the volume.
2.
Amazon Elastic Compute Cloud Getting Started Guide Step 2: Launch an Amazon EC2 Instance
3.
The Create a New Instance page includes these ways to launch an instance: The Classic Wizard offers you precise control and advanced settings for configuring your instance. The Quick Launch Wizard automatically configures many selections for you, so that you can get started quickly. This tutorial guides you through the Quick Launch Wizard.
4. 5. 6.
On the Create a New Instance page, click Quick Launch Wizard. (Optional) In Name Your Instance, enter a name for the instance that has meaning for you. (If you run multiple instances, naming them helps you identify them in the console.) In Choose a Key Pair, you can choose from any existing key pairs that you've created, or you can create a new key pair. A key pair enables you to connect to a Linux instance through SSH. Therefore, don't select the None option. If you launch your instance without a key pair, then you can't connect to it. For this example, well create a key pair: a. b. c. Click Create New. Type a name for your key pair and then click Download. Save your private key in a safe place on your computer. Note the location because you'll need the key to connect to your instance.
7.
In Choose a Launch Configuration, the Quick Launch Wizard displays a list of basic configurations called Amazon Machine Images (AMIs) that you can choose from to launch your instance. An AMI contains everything you need to create a new instance of a server, such as a web server or a database server. In this tutorial, well launch an Amazon Linux instance with a 64-bit operating system. If the configuration is marked with a star, this indicates that it's within the Free Usage Tier.
Amazon Elastic Compute Cloud Getting Started Guide Step 2: Launch an Amazon EC2 Instance
Important
If you launch a regular instance, you're billed from the time that you launch the instance until the instance is stopped or terminated, even if it remains idle.
8. 9.
Click Continue to view and customize the settings for your instance. In Security Details, Security Group, you see the security group that the wizard selects for you. A security group defines firewall rules for your instances.These rules specify which incoming network traffic is 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. The name and description for the group is quicklaunch-x where x is a number associated with your quicklaunch group. The first security group you create using the Quick Launch Wizard is named quicklaunch-1. You can change the name and description using the Edit details button. The group already has basic firewall rules that enable you to connect to the type of instance you choose. For a Linux instance, you connect through SSH on port 22. The quicklaunch-x security group automatically allows SSH traffic on port 22. If you have used Amazon EC2 before, the wizard looks for an existing security group for the type of instance youre creating.
Caution
The quicklaunch-x security group authorizes all IP addresses to access your instance over the specified ports (for example, SSH). 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 IP addresses to access your instance.
Amazon Elastic Compute Cloud Getting Started Guide Step 2: Launch an Amazon EC2 Instance
10. Review your settings, and click Launch to launch the instance. 11. A confirmation page lets you know that your instance is launching. Click Close to close the confirmation page and return to the Amazon EC2 console. 12. In the Navigation pane, click Instances to view the status of your instance. It takes a short time for an instance to launch. The instance's status is pending while it's launching.
13. (Optional) After your instance is launched, you can view the quicklaunch-x security group rules. a. b. On the Amazon EC2 console, in Network and Security, click Security Groups. Click the quicklaunch-1 security group to view the security rules created by the Quick Launch Wizard.
Amazon Elastic Compute Cloud Getting Started Guide Step 3: Connect to Your Instance
The security group contains a rule that authorizes SSH traffic from any IP address source to port 22. If you launch a Linux instance running Apache and MySQL, the Quick Launch Wizard creates a security group that authorizes traffic to port 80 for HTTP (for web traffic) and port 3306 (for MySQL).
2. 3. 4. 5.
Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. In the Navigation pane, click Instances. Right-click your instance, and then click Connect. Click Connect from your browser using the Java SSH client (Java Required). AWS automatically detects the public DNS address of your instance and the key pair name you launched the instance with. In User name, enter the user name to log in to your instance.
6.
Note
For an Amazon Linux instance, the default user name is ec2-user. For Ubuntu, the default user name is ubuntu. Some AMIs allow you to log in as root. So in this example, you may need to change the user name from ec2-user to the appropriate user name. 7. 8. The Key name field is automatically populated for you. In Private key path, enter the fully qualified path to your .pem private key file.
Amazon Elastic Compute Cloud Getting Started Guide Step 4: Explore Your Instance
9.
Click Save key location, and then click Stored in browser cache to store the key location in your browser cache. This ensures that the key location will be detected in subsequent browser sessions, until your clear your browsers cache. 10. Click Launch SSH Client.
When prompted to add the host to your set of known hosts, click No. If necessary, click Yes to trust the certificate. Click Run to run the MindTerm client. If you accept the license agreement, click Accept. If this is your first time running MindTerm, a series of dialog boxes ask you to confirm setup for your home directory and other settings. 16. Confirm settings for MindTerm setup. A screen opens and you are connected to your instance. Congratulations! You've successfully launched and connected to a Linux instance. If you'd like to explore the instance, continue to the next step. Otherwise, skip to Step 5: Clean Up (p. 9) to terminate the instance so that you don't continue to incur charges.
For a micro instance, your output should look something like this.
Amazon Elastic Compute Cloud Getting Started Guide Step 4: Explore Your Instance
Used 1.1G 0
The /dev/xvda1 volume is the root device volume. It contains the image used to boot the instance. Notice that there's room to install additional software on your instance. For example, you can use yum to download and install packages on your instance. If you need additional storage for data, a simple solution is to add Amazon Elastic Block Store (Amazon EBS) volumes to your Amazon EC2 instance. An Amazon EBS volume serves as network-attached storage for your instance. Let's add a volume to the instance that you've launched. First we'll use the EC2 console to create an Amazon EBS volume and attach it to the instance, and then we'll connect to the instance and mount the volume.
3.
4. 5.
Now click Yes, Create. This creates a new volume (its state is available, and its snapshot is snap-2767d046). 6. 7. Right-click the newly created volume and select Attach Volume. In the Attach Volume dialog box, click the following settings: Select your Linux instance from the list. Specify the device name /dev/sdf.
Now click Yes, Attach.You'll notice in the Details pane for your volume that the volume state is in-use and that it is attached to your instance with the device name /dev/sdf. However, if you return to MindTerm and run the df -h command again, you won't see the volume yet. That's because we need to mount the volume to make it available. To mount a volume based on a snapshot, run the following commands.
Note
If you didn't specify a snapshot when you created the volume, the new volume is an empty volume. Before you can mount an empty volume that you create, you must format it using the sudo mkfs command. For more information, see Making an Amazon EBS Volume Available for Use. Now when you run the df -h command, you'll see output like the following.
Filesystem /dev/xvda1 tmpfs /dev/xvdf Size 8.6G 313M 5.0G Used 1.2G 0 4.3G Avail Use% Mounted on 7.4G 14% / 313M 0% /dev/shm 442M 91% /mnt/song-data
To view the contents of the new volume, run the following command.
$ dir /mnt/song-data
At this point, you should have a basic understanding of instances and how you work with them. When you're finished with your instance, don't forget to clean up any resources you've used and terminate the instance, as shown in the next step.
Step 5: Clean Up
Now that youve completed this tutorial, you can customize the instance to meet your needs and keep using it.
Important
Remember, if you launched an instance in the Free Usage Tier, there are no charges. However, if you launched a regular instance, as soon as your instance starts to boot, you're billed for each hour or partial hour that you keep the instance running, even if the instance is idle. You'll stop incurring charges for a regular instance as soon as the instance status changes to shutting down or terminated. When you've decided that you no longer need the instance, you can terminate it. Terminating an instance effectively deletes it. You can't reconnect to the instance after you've terminated it. This differs from stopping the instance; you are still charged for a stopped instance, and you can restart a stopped instance. For information about the differences between stopping an instance and terminating an instance, see Stopping Instances.
Amazon Elastic Compute Cloud Getting Started Guide Finding Additional Tutorials
4.
Click Yes, Terminate when prompted for confirmation. Amazon EC2 begins terminating the instance.
Amazon EBS volumes can persist even after your instance goes away. If you created and attached an EBS volume in the previous step, it was detached when you terminated the instance. However, you must delete the volume, or you'll be charged for volume storage if the storage amount exceeds the limit of the Free Usage Tier. After you delete a volume, its data is gone and the volume can't be attached to any instance.
Amazon Elastic Compute Cloud Getting Started Guide AWS Account and Security Credentials
Amazon Elastic Compute Cloud Getting Started Guide Use the Command Line Interface
Compute Cloud User Guide. The console also has online Help to assist you; just click the Help button in the console.
For libraries and sample code in all languages, go to Amazon EC2 Sample Code & Libraries.
Amazon Elastic Compute Cloud Getting Started Guide Importing Your Own Virtual Machines
needed and create your own custom AMIs from them. For general information about AMIs, go to AMIs and to Creating Your Own AMIs in the Amazon Elastic Compute Cloud User Guide. You can choose between Amazon S3 or Amazon Elastic Block Store as the root device for your AMI (for a brief description of Amazon EBS, see Amazon Elastic Block Store (p. 14) later in this section). We recommend using instances backed by Amazon EBS, because they launch faster and use persistent storage. For more information, go to AMIs Backed by Amazon EBS in the Amazon Elastic Compute Cloud User Guide.
Instance Types
To meet the needs of different organizations and applications, Amazon EC2 instances are available in different sizes and CPU/memory configurations. For more information, go to Instances in the Amazon Elastic Compute Cloud User Guide.
Tags
You can add optional metadata to your instances, AMIs, and other EC2 resources to help you categorize and manage them. For more information, go to Using Tags in the Amazon Elastic Compute Cloud User Guide.
Elastic IP Addresses
You might want to have static IP addresses for your instances. Amazon EC2 provides elastic IP addresses that can be dynamically remapped to different instances. For more information, go to Elastic IP Addresses in the Amazon Elastic Compute Cloud User Guide.
Security Groups
You might be concerned about keeping others from accessing your instances, both inside and outside the Amazon network.You can create other security groups (beyond the basic group we used in this guide) to meet your security requirements. For more information, go to Network Security Concepts in the Amazon Elastic Compute Cloud User Guide.
Availability Zones
You might want to build a geographically dispersed, fault tolerant architecture on Amazon EC2. You can place instances in different geographic regions and isolate instances within those regions using Availability Zones. This provides geographic flexibility and affordable fault tolerance. For more information, go to Region and Availability Zone Concepts in the Amazon Elastic Compute Cloud User Guide.
Amazon Linux
AWS provides Amazon Linux AMIs, which are supported and maintained Linux images optimized for the EC2 environment. For more information, go to Amazon Linux AMI.
Amazon Elastic Compute Cloud Getting Started Guide Amazon EC2 Running Windows
Reserved Instances
You might want to run a set of full-time or nearly full-time instances but also bring down your costs. Amazon EC2 supports an additional pricing option that enables you to make a low one-time payment for each instance to reserve and receive a significant discount on the hourly usage charge for that instance. For more information, go to On-Demand and Reserved Instances and to Reserving Amazon EC2 Instances in the Amazon Elastic Compute Cloud User Guide.
Spot Instances
If you're flexible about when you need instances and want to bring down your costs, Amazon EC2 lets you bid for unused Amazon EC2 capacity and run your instances for as long as your bid exceeds the current Spot Price. For more information, go to the Amazon EC2 Spot Instances product page and Introduction to Spot Instances.
Monitoring Instances
You might need a solution for monitoring your instances. Amazon CloudWatch is a monitoring service for Amazon EC2 that is designed to gather, aggregate, store, and retrieve metrics. For more information, go to the Amazon CloudWatch product page and the Amazon CloudWatch Developer Guide.
Load Balancing
You might need a solution for load balancing requests to your instances. Elastic Load Balancing offers the ability to evenly spread requests across your running Amazon EC2 instances. For more information, go to the Elastic Load Balancing product page and the Elastic Load Balancing Developer Guide.
Micro Instances
Amazon EC2 offers micro instances, which provide a small amount of consistent CPU resources and allow you to burst CPU capacity when additional cycles are available. They are well suited for lower throughput applications and web sites that consume significant compute cycles periodically. For more information, go to Micro Instance Concepts in the Amazon Elastic Compute Cloud User Guide.
Cluster Instances
Amazon EC2 offers cluster instances for your High-Performance Computing (HPC) applications. These instances provide you with high-bandwidth, low-latency inter-node communications for advanced computational applications such as computational fluid dynamics, computational biology, and materials research. For more information, go to Using Cluster Instances in the Amazon Elastic Compute Cloud User Guide.
Contact Us
You can also find additional information about Amazon EC2 in the Amazon EC2 Articles & Tutorials area of the AWS web site.
Document History
The following table describes the important changes to this guide. Change Explore your instance Description We've added a new section that steps you through attaching an Amazon EBS volume to your instance and making it available for use. Structurally, the tutorial pages were consolidated into a single web page.This web page is also included in the Amazon Elastic Compute Cloud User Guide. Use the New Java-Based SSH Client You can connect to your Linux instance from your web browser using 5 March 2012 a Java-based SSH client. Release Date 19 October 2012
Public Release The first release of the Amazon Elastic Compute Cloud Getting Started Guide.