Ec2 Ug
Ec2 Ug
Ec2 Ug
Welcome ................................................................................................................................................. 1 What is Amazon EC2? ............................................................................................................................ 4 Getting Started ..................................................................................................................................... 12 Amazon Machine Images ..................................................................................................................... 22 AMI Basics ............................................................................................................................................ 22 Finding a Suitable AMI .......................................................................................................................... 25 Shared AMIs ......................................................................................................................................... 28 Paid AMIs ............................................................................................................................................. 30 Creating Amazon EBS-Backed AMIs Using the Console ..................................................................... 32 Creating Your Own AMIs ....................................................................................................................... 34 Creating Amazon EBS-Backed Linux AMIs ................................................................................. 35 Creating Instance Store-Backed Linux/UNIX AMIs .................................................................... 38 Tools You Need .................................................................................................................. 39 From an Existing AMI ......................................................................................................... 40 From a Loopback ............................................................................................................... 44 Creating Paid AMIs ..................................................................................................................... 52 Sharing AMIs Safely .................................................................................................................... 61 Copying AMIs ....................................................................................................................................... 69 Amazon Linux AMIs .............................................................................................................................. 73 Enabling Your Own Linux Kernels ................................................................................................ 80 Instances .............................................................................................................................................. 88 Instance Basics ..................................................................................................................................... 89 Families and Types ...................................................................................................................... 89 Micro Instances .................................................................................................................. 96 High I/O Instances ........................................................................................................... 103 High Storage Instances .................................................................................................... 104 Cluster Instances ............................................................................................................. 106 Regions and Availability Zones ................................................................................................. 119 Supported Platforms ................................................................................................................. 124 Root Device Volume .................................................................................................................. 127 Best Practices ........................................................................................................................... 133 Spot Instances .................................................................................................................................... 135 Getting Started with Spot Instances .......................................................................................... 136 Viewing Spot Price History .............................................................................................. 139 Creating a Spot Instance Request ................................................................................... 142 Finding Running Spot Instances ...................................................................................... 147 Canceling Spot Instance Requests .................................................................................. 150 Fundamentals ............................................................................................................................ 153 Placing Spot Bids ............................................................................................................. 153 Tracking Spot Requests with Bid Status Codes ...................................................... 154 Tagging Spot Instance Requests ..................................................................................... 159 Protecting Your Spot Instance Data Against Interruptions ............................................... 160 Planning for Interruptions ....................................................................................... 160 Persist Your Root EBS Partition .............................................................................. 161 Walkthroughs: Using Spot Instances with AWS Services ......................................................... 161 Managing Spot Instances with Auto Scaling .................................................................... 162 Tools for Managing Auto Scaling with Spot Instances ............................................ 163 Launching Spot Instances with Auto Scaling .......................................................... 164 Obtaining Information About the Instances Launched by Auto Scaling .................. 167 Updating the Bid Price for the Spot Instances ........................................................ 171 Scheduling Spot Bid Requests ............................................................................... 173 Using Auto Scaling to Get Notifications for Spot Instances .................................... 174 Using CloudFormation Templates to Launch Spot Instances .......................................... 177 Launching Amazon Elastic MapReduce Job Flows with Spot Instances ......................... 178 Launching Spot Instances in Amazon Virtual Private Cloud ............................................ 178 Advanced Tasks ........................................................................................................................ 180 Subscribe to Your Spot Instance Data Feed .................................................................... 180 Programming Spot with AWS Java SDK .......................................................................... 183
API Version 2013-02-01 4
Tutorial: Amazon EC2 Spot Instances .................................................................... 184 Tutorial: Advanced Amazon EC2 Spot Request Management ............................... 194 Starting Clusters on Spot Instances ................................................................................ 210 Reserved Instances ............................................................................................................................ 212 Tools and Prerequisites ............................................................................................................. 215 Understanding the Pricing Benefit and Consolidated Billing ..................................................... 217 Reserved Instances and Consolidated Billing .................................................................. 218 Understanding Reserved Instance Pricing Tiers ....................................................................... 220 Working with Reserved Instances ............................................................................................. 228 Reserved Instance Marketplace ......................................................................................................... 234 Selling in the Reserved Instance Marketplace .......................................................................... 236 Registering as a Seller ..................................................................................................... 237 Selling Your Reserved Instances ...................................................................................... 241 After Your Reserved Instance Is Sold ............................................................................... 260 Buying in the Reserved Instance Marketplace .......................................................................... 263 Becoming a Buyer ............................................................................................................ 264 Purchasing Your Reserved Instances .............................................................................. 264 Reading Your Statement (Invoice) .................................................................................... 271 Launching Instances ........................................................................................................................... 274 Launching an Instance from an AMI .......................................................................................... 274 Creating and Launching an AMI from a Snapshot .................................................................... 280 Connecting to Amazon EC2 Instances ............................................................................................... 282 Getting an SSH Key Pair ........................................................................................................... 282 Authorizing Network Access to Your Instances ......................................................................... 295 Connecting to Linux/UNIX Instances Using SSH ...................................................................... 298 Connecting to Linux/UNIX Instances from Windows Using PuTTY ........................................... 304 Connecting to Windows Instances ............................................................................................ 309 Importing and Exporting Instances ..................................................................................................... 318 Importing EC2 Instances ........................................................................................................... 318 Before You Get Started .................................................................................................... 320 Using the Amazon EC2 VM Import Connector to Import Your Virtual Machine to Amazon EC2 .................................................................................................................................. 321 Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2 ............ 335 Exporting EC2 Instances ........................................................................................................... 347 Managing Instances ............................................................................................................................ 349 Auto Scaling and Load Balancing Your Instances ..................................................................... 349 Monitoring Your Instances ......................................................................................................... 351 Monitoring Your Instances with CloudWatch .................................................................... 352 Monitoring the Status of Your Instances ........................................................................... 363 Monitoring Instances with Status Checks ............................................................... 363 Monitoring Events for Your Instances ...................................................................... 367 Ensuring Idempotency .............................................................................................................. 372 Instance Metadata ..................................................................................................................... 374 Stopping Instances ............................................................................................................................. 384 Stopping and Starting Instances ............................................................................................... 386 Terminating Instances ............................................................................................................... 388 Enabling Termination Protection ................................................................................................ 390 Changing the Shutdown Behavior ............................................................................................. 393 Modifying Attributes of a Stopped Instance ............................................................................... 396 Troubleshooting Instances .................................................................................................................. 399 Instances with Failed Status Checks ......................................................................................... 399 What to Do If an Instance Immediately Terminates ................................................................... 422 Getting Console Output and Rebooting Instances .................................................................... 423 Network and Security ......................................................................................................................... 425 Security Groups .................................................................................................................................. 426 Amazon EC2 Credentials ................................................................................................................... 442 AWS Identity and Access Management .............................................................................................. 446 Amazon VPC ...................................................................................................................................... 454
API Version 2013-02-01 5
Instance IP Addressing ....................................................................................................................... 457 Elastic IP Addresses ........................................................................................................................... 466 Elastic Network Interfaces .................................................................................................................. 471 Storage ............................................................................................................................................... 482 Amazon EBS ...................................................................................................................................... 484 Increasing EBS Performance .................................................................................................... 489 Creating a Volume ..................................................................................................................... 498 Attaching a Volume to an Instance ............................................................................................ 500 Describing Volumes ................................................................................................................... 503 Making an Amazon EBS Volume Available for Use ................................................................... 505 Monitoring the Status of Your Volumes ...................................................................................... 508 Detaching a Volume from an Instance ....................................................................................... 519 Deleting a Volume ..................................................................................................................... 521 Creating a Snapshot .................................................................................................................. 522 Copying a Snapshot .................................................................................................................. 524 Describing Snapshots ............................................................................................................... 526 Modifying Snapshot Permissions .............................................................................................. 528 Deleting a Snapshot .................................................................................................................. 530 Using Public Data Sets .............................................................................................................. 532 API and Command Overview .................................................................................................... 534 Instance Store ..................................................................................................................................... 536 Amazon S3 ......................................................................................................................................... 544 Block Device Mapping ........................................................................................................................ 545 Resources and Tags ........................................................................................................................... 560 Resource Locations ............................................................................................................................ 560 Listing and Filtering Your Resources .................................................................................................. 562 Tagging Your Resources ..................................................................................................................... 566 Setting Up the Tools ............................................................................................................................ 579 Verify the Signature ............................................................................................................................ 580 Making API Requests ......................................................................................................................... 589 Query Requests .................................................................................................................................. 590 SOAP Requests .................................................................................................................................. 592 Technical FAQ ..................................................................................................................................... 593 General Information FAQ .................................................................................................................... 593 Instances and AMIs Information FAQ ................................................................................................. 594 Operation Information FAQ ................................................................................................................. 595 Instance Types and Architectures FAQ ............................................................................................... 596 IP Information FAQ ............................................................................................................................. 598 Region and Availability Zone FAQ ...................................................................................................... 600 Windows Instances FAQ ..................................................................................................................... 602 Monitoring, Errors, and Unexpected Behavior FAQ ............................................................................ 602 Reserved Instances FAQs .................................................................................................................. 603 Paid AMIs FAQ ................................................................................................................................... 605 Error Messages FAQ .......................................................................................................................... 606 Miscellaneous FAQ ............................................................................................................................. 607 Document History ............................................................................................................................... 608
How Do I...?
How Do I? Get a general overview of the product and information about pricing Relevant Topics Amazon EC2 product page
Get a quick, hands-on introduction to Amazon EC2 Getting Started with Amazon EC2 Linux Instances (p. 12) Getting Started with Amazon EC2 Windows Instances Get a quick summary of the basic infrastructure components that Amazon EC2 provides Get detailed information about how to use the Amazon EC2 components and features, with instructions for several different interfaces What is Amazon EC2? (p. 4)
Amazon Machine Images (AMI) (p. 22) Amazon EC2 Instances (p. 88) Amazon Elastic Block Store (Amazon EBS) (p. 484) Network and Security (p. 425)
Get information specific to using Amazon EC2 with Amazon Elastic Compute Cloud Microsoft Windows the Windows Server operating system. Guide
How Do I?
Relevant Topics
Start using the command line tools (also known as Setting Up the Amazon EC2 Command Line the Amazon EC2 API tools) Tools (p. 579) Amazon Elastic Compute Cloud Command Line Reference Start using the Query API Making API Requests (p. 589) Amazon Elastic Compute Cloud API Reference Available Libraries (p. 590)
Note
The content from the original Amazon Elastic Compute Cloud Developer Guide is included in this guide.
Contact Us
Additional Resources
Getting Started with AWS
Main Components
As you get started with Amazon EC2, you should understand the main Amazon EC2 components and how they are similar to or different from your own data centers. This section provides a brief description of the main components of Amazon EC2. Topics Amazon Machine Images and Instances (p. 5) Regions and Availability Zones (p. 5) Storage (p. 6) Databases (p. 8) Networking and Security (p. 8) Monitoring, Auto Scaling, and Load Balancing (p. 8) AWS Identity and Access Management (p. 9)
Amazon Elastic Compute Cloud User Guide Amazon Machine Images and Instances
Your instances keep running until you stop or terminate them, or until they fail. If an instance fails, you can launch a new one from the AMI. For information about AMIs and instances, see Amazon Machine Images (AMI) (p. 22) and Amazon EC2 Instances (p. 88).
For more information about the available regions and Availability Zones, see Regions and Availability Zones (p. 119).
Storage
When using an instance, you may have data that you need to store. Amazon EC2 offers the following storage options: Amazon Elastic Block Store (Amazon EBS) Amazon EC2 Instance Store (p. 536) Amazon Simple Storage Service (Amazon S3) The following figure shows the relationship between these types of storage.
Amazon EBS
Amazon EBS volumes are the recommended storage option for the majority of use cases. Amazon EBS provides your instances with persistent, block-level storage. Amazon EBS volumes are essentially hard disks that you can attach to a running instance. Amazon EBS is especially suited for applications that require a database, a file system, or access to raw block-level storage.
As illustrated in the previous figure, you can attach multiple volumes to an instance. Also, to keep a back-up copy of your data, you can create a snapshot of an EBS volume, which is stored in Amazon S3. You can create a new Amazon EBS volume from a snapshot, and attach it to another instance. You can also detach a volume from an instance and attach it to a different instance. The following figure illustrates the life cycle of an EBS volume.
For more information about Amazon EBS volumes, see Amazon Elastic Block Store (Amazon EBS) (p. 484).
Instance Store
All instance types, with the exception of Micro instances, offer instance store, which provides your instances with temporary, block-level storage. This is storage that is physically attached to the host computer. The data on an instance store volume doesn't persist when the associated instance is stopped or terminated. For more information about instance store volumes, see Amazon EC2 Instance Storage (p. 536). Instance store is an option for inexpensive temporary storage. You can use instance store volumes if you don't require data persistence.
Amazon S3
Amazon S3 is storage for the Internet. It provides a simple web service interface that enables you to store and retrieve any amount of data from anywhere on the web. For more information about Amazon S3, see Amazon Simple Storage Service (Amazon S3).
The description of an AMI indicates the type of root device (either ebs or instance store). This is important because there are significant differences in what you can do with each type of AMI. For more information about these differences, see Storage for the Root Device (p. 23).
Databases
The application you're running on Amazon EC2 may need a database. The following are common ways to implement a database for your application: Use Amazon Relational Database Service (Amazon RDS), which enables you to easily get a managed relational database in the cloud Launch an instance of a database AMI, and use that EC2 instance as the database Amazon RDS offers the advantage of handling your database management tasks, such as patching the software, backing up, and storing the backups. For more information about Amazon RDS, see the Amazon RDS product page.
Automatically scale your Amazon EC2 capacity up Auto Scaling Developer Guide or down according to the conditions that you define. Automatically distribute incoming application traffic Elastic Load Balancing Developer Guide across multiple Amazon EC2 instances.
Amazon Elastic Compute Cloud User Guide AWS Identity and Access Management
Programmatic Interfaces
The following table lists the resources that you can use to access EC2 programmatically.
Amazon Elastic Compute Cloud User Guide How You're Charged for EC2
Description AWS SDKs include sample code, libraries, tools, documentation, and templates. To download the AWS SDKs, see AWS Software Development Kits (SDKs).
Libraries
Developers can provide their own libraries, which you can find at the following AWS developer centers: Java Developer Center Mobile Developer Center PHP Developer Center Python Developer Center Ruby Developer Center Windows and .NET Developer Center
EC2 API
If you prefer, you can code directly to the EC2 API. For more information, see Making API Requests (p. 589) , and see the Amazon Elastic Compute Cloud API Reference.
5.
If you cancel AWS, this cancels all services, including EC2. Under Cancel Your AWS Account page, click Cancel Your AWS Account. Alternatively, you can cancel individual services; go to Cancel Selected Services, select Amazon Elastic Compute Cloud, and then click Cancel Service.
What's Next?
This section introduced you to the basic infrastructure components that EC2 offers. What should you do next?
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. 13) cloud. Step 3: Connect to Your Instance (p. 17) Step 4: Explore Your Instance (p. 18) 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 User 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 User Guide Step 2: Launch an Amazon EC2 Instance
3.
From the Amazon EC2 console dashboard, click Launch Instance. 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.
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.
Amazon Elastic Compute Cloud User Guide Step 2: Launch an Amazon EC2 Instance
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 User 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. Click Instances in the navigation pane 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 User 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/. Click Instances in the navigation pane. 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. 9. The Key name field is automatically populated for you. In Private key path, enter the fully qualified path to your .pem private key file.
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.
API Version 2013-02-01 17
Amazon Elastic Compute Cloud User Guide Step 4: Explore Your Instance
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. 20) to terminate the instance so that you don't continue to incur charges.
For a micro instance, your output should look something like this.
Filesystem /dev/xvda1 tmpfs Size 8.0G 298M Used 1.1G 0 Avail Use% Mounted on 6.9G 14% / 298M 0% /dev/shm
Amazon Elastic Compute Cloud User Guide Step 4: Explore Your Instance
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.
$ sudo mkdir /mnt/song-data $ sudo mount /dev/sdf /mnt/song-data
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 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.
Related Topics
Amazon EC2 Instances (p. 88) Tagging Your Amazon EC2 Resources (p. 566)
AMI Basics
An AMI contains all information necessary to boot an Amazon EC2 instance with your software. An AMI is like a template of a computer's root volume. For example, an AMI might contain the software to act as a web server (Linux, Apache, and your web site) or it might contain the software to act as a Hadoop node (Linux, Hadoop, and a custom application). You launch one or more instances from an AMI. An instance might be one web server within a web server cluster or one Hadoop node. Topics Available AMIs (p. 23) Storage for the Root Device (p. 23)
Available AMIs
Public AMIs can be launched by all AWS accounts. They are advertised and shared in the AWS AMI catalog. Amazon and the Amazon EC2 community provide a large selection of public AMIs. For more information, go to Amazon Machine Images (AMIs) on the AWS website. Paid AMIs are AMIs that you purchase from the AWS Marketplace, developers, or through a service contract from an organization such as Red Hat. If you are interested in the AWS Marketplace, visit AWS Marketplace. If you're interested in selling an AMI to other developers, go to http://aws.amazon.com/devpay. The AWS Management Console (at http://aws.amazon.com/console) enables you to search for an AMI that meets specific criteria, and then launch instances from that AMI. For example, you can view the AMIs that Amazon has provided, the AMIs that the EC2 community has provided, or AMIs that use a certain platform (such as Windows, Red Hat, CentOS, or Ubuntu). You might find that public AMIs suit your needs. However, you might want to customize a public AMI and save that customized AMI for your own use later on. For more information about creating your own AMIs, see Creating Your Own AMIs (p. 34). After you create a new AMI, you can keep it private so that only you can use it, or you can share it with only specific AWS accounts that you specify. Another option is to make your customized AMI public so that the EC2 community can use it. Building safe, secure, usable AMIs for public consumption is a fairly straightforward process, if you follow a few simple guidelines. For information on how to use shared AMIs and how to share AMIs, see Shared AMIs (p. 28) and Sharing AMIs Safely (p. 61). To help categorize and manage your AMIs, you can assign tags of your choice to them. For more information, see Tagging Your Amazon EC2 Resources (p. 566).
Upgrading
The instance type, kernel, RAM disk, Instance attributes are fixed for the life and user data can be changed while of an instance the instance is stopped.
Amazon Elastic Compute Cloud User Guide Storage for the Root Device
Characteristic Charges
Amazon EBS-Backed
Instance usage, Amazon EBS volume Instance usage and Amazon S3 usage, and Amazon EBS snapshot charges for AMI storage charges for AMI storage Uses a single command/call Requires installation and use of AMI tools
AMI Creation/Bundling
Stopped State
Can be placed in stopped state where Cannot be in stopped state; instances instance is not running, but the are running or terminated instance is persisted in Amazon EBS
Size Limit
Amazon EC2 instance store-backed AMIs are limited to 10 GiB storage for the root device, whereas Amazon EBS-backed AMIs are limited to 1 TiB. Many Windows AMIs come close to the 10 GiB limit, so you'll find that Windows AMIs are often backed by an Amazon EBS volume.
Note
All Windows Server 2008, Windows Server 2008 R2, and Windows Server 2012 AMIs are backed by an Amazon EBS volume by default because of their larger size.
Stopped State
You can stop an Amazon EBS-backed instance, but not an Amazon EC2 instance store-backed instance. Stopping causes the instance to stop running (its status goes from running to stopping to stopped). A stopped instance persists in Amazon EBS, which allows it to be restarted. Stopping is different from terminating; you can't restart a terminated instance. Because Amazon EC2 instance store-backed AMIs can't be stopped, they're either running or terminated. For more information about what happens and what you can do while an instance is stopped, see Stopping Instances (p. 384).
Boot Times
Amazon EBS-backed AMIs launch faster than Amazon EC2 instance store-backed AMIs. When you launch an Amazon EC2 instance store-backed AMI, all the parts have to be retrieved from Amazon S3 before the instance is available. With an Amazon EBS-backed AMI, only the parts required to boot the instance need to be retrieved from the snapshot before the instance is available. However, the performance of an instance that uses an Amazon EBS volume for its root device is slower for a short time while the remaining parts are retrieved from the snapshot and loaded into the volume. When you stop and restart the instance, it launches quickly, because the state is stored in an Amazon EBS volume.
AMI Creation
To create Linux/UNIX AMIs backed by instance store, you must create an image of your instance on the instance itself, but there aren't any API actions to help you. To create a Windows AMI backed by instance store, there's an API action that creates an image and another API action that registers the AMI. AMI creation is much easier for AMIs backed by Amazon EBS. The CreateImage API action creates the AMI on both Linux/UNIX and Windows. This API action creates your Amazon EBS-backed AMI and registers it. There's also a button in the AWS Management Console that lets you create an image from a running instance. For more information, see Creating Amazon EBS-Backed Linux AMIs (p. 35).
4.
5.
The following example shows only part of the resulting output from the command (information for 10 AMIs).
IMAGE ami-d8699bb1 amazon/ami-vpc-nat-1.0.0-beta.i386-ebs amazon available public i386 machine aki-407d9529 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-33d88c5f 8 IMAGE ami-c6699baf amazon/ami-vpc-nat-1.0.0-beta.x86_64-ebs amazon available public x86_64 machine aki-427d952b ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-57d88c3b 8 IMAGE ami-30f30659 amazon/amzn-ami-0.9.7-beta.i386-ebs amazon available public i386 machine aki-407d9529 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-d895cdb3 10 IMAGE ami-0af30663 amazon/amzn-ami-0.9.7-beta.x86_64-ebs amazon available public x86_64 machine aki-427d952b ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-f295cd99 10 IMAGE ami-3ac33653 amazon/amzn-ami-0.9.8-beta.i386-ebs amazon available public i386 machine aki-407d9529 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-14ba967f 10 IMAGE ami-38c33651 amazon/amzn-ami-0.9.8-beta.x86_64-ebs amazon available public x86_64 machine aki-427d952b ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-10b9957b 10 IMAGE ami-08728661 amazon/amzn-ami-0.9.9-beta.i386-ebs amazon available public i386 machine aki-407d9529 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-674a930d 10 IMAGE ami-2272864b amazon/amzn-ami-0.9.9-beta.x86_64-ebs amazon available public x86_64 machine aki-427d952b ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-8926ffe3 10 IMAGE ami-76f0061f amazon/amzn-ami-2010.11.1-beta.i386-ebs amazon available public i386 machine aki-407d9529 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-cba692a1 8 IMAGE ami-74f0061d amazon/amzn-ami-2010.11.1-beta.x86_64-ebs amazon available public x86_64 machine aki-427d952b ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-ffa69295 8 IMAGE ami-8c1fece5 amazon/amzn-ami-2011.02.1.i386-ebs amazon available public i386 machine aki-407d9529 ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-22fc264e 8 IMAGE ami-8e1fece7 amazon/amzn-ami-2011.02.1.x86_64-ebs amazon available public x86_64 machine aki-427d952b ebs paravirtual xen BLOCKDEVICEMAPPING /dev/sda1 snap-a6fc26ca 8
2. 3.
To reduce the number of displayed AMIs, use a filter to list only the types of AMIs that interest you. For example, use --filter "platform=windows" to display only Windows-based AMIs. After locating an AMI that meets your needs, write down its AMI ID, which has the form ami-xxxxxxxx. You can use this ID to launch instances of the AMI or register your own AMI, using this one as a baseline.
API
To find a suitable AMI
1. Use the DescribeImages action to list all Amazon s. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DescribeImages &User.1=amazon &AUTHPARAMS
2.
To reduce the number of displayed AMIs, use a filter to list only the types of AMIs that interest you. For example, use the following to display only Windows-based AMIs.
&Filter.1.Name=platform &Filter.1.Value.1=windows
3.
After locating an AMI that meets your needs, write down its AMI ID, which has the form ami-xxxxxxxx. You can use this ID to launch instances of the AMI or register your own AMI, using this one as a baseline.
API Version 2013-02-01 27
Shared AMIs
This topic describes how to find and safely use shared AMIs. One of the easiest ways to get started with Amazon EC2 is to use a shared AMI that has the components you need and add custom content. Topics Find Shared AMIs (p. 28) Safe Use of Shared AMIs (p. 29)
The following command displays a list of AMIs for which you have explicit launch permissions. Any such AMIs that you own are excluded from the list.
PROMPT> ec2-describe-images -x self
The following command displays a list of AMIs owned by a particular AWS account.
PROMPT> ec2-describe-images -o <target_uid>
The <target_uid> is the account ID that owns the AMIs you're looking for.
Amazon Elastic Compute Cloud User Guide Safe Use of Shared AMIs
To reduce the number of displayed AMIs, use a filter to list only the types of AMIs that interest you. For example, use --filter "platform=windows" to display only Windows-based AMIs.
API
To find a shared AMI
1. Use the DescribeImages action to to list all Amazon s. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DescribeImages &User.1=amazon &AUTHPARAMS
2.
To reduce the number of displayed AMIs, use a filter to list only the types of AMIs that interest you. For example, use the following to display only Windows-based AMIs.
&Filter.1.Name=platform &Filter.1.Value.1=windows
Note
Users cannot alias an AMI's owner. If you plan to use a shared AMI, review the following table to confirm the instance is not doing anything malicious.
2 3
Check whether there are any other user accounts that might allow back-door entry to your instance. Accounts with super user privileges are particularly dangerous. Verify that all cron jobs are legitimate.
Paid AMIs
Topics Find Paid AMIs (p. 30) Purchase a Paid AMI (p. 31) Launch Paid AMIs (p. 31) Using Paid Support (p. 31) Bills for Paid and Supported AMIs (p. 32) Amazon EC2 integrates with Amazon DevPay, enabling developers to charge other Amazon EC2 users for the use of their AMIs or to provide support for instances. For more information about Amazon DevPay, see the Amazon DevPay Developer Guide. For more information about charging for the use of your AMIs, or providing support, see Creating Paid AMIs (p. 52). This section describes how to discover paid AMIs, launch paid AMIs, and launch instances with a support product code. Paid AMIs are AMIs you can purchase from other developers.
Note
You must sign up for a paid AMI before you can launch it. If you find a paid AMI that you are interested in, go to the Amazon EC2 resource center and forums, which might have more information about the paid AMI and where you can sign up to use it.
The <ami_id> is the ID of the AMI. The command returns numerous fields that describe the AMI. If the output for the AMI contains a product code, the AMI is a paid AMI. This example shows ec2-describe-images output for a paid AMI. The product code is ACD42B6F.
PROMPT> ec2-describe-images ami-a5bf59cc IMAGE ami-a5bf59cc cloudmin-2.6-paid/image.manifest.xml 541491349868 available public ACD42B6F i386 machine instance-store
2.
Important
You don't get the discount from Amazon EC2 Reserved Instances with paid AMIs. That is, if you purchase Reserved Instances, you don't get the lower price associated with them when you launch a paid AMI. You always pay the price that the seller of the paid AMI specified. For more information, see Reserved Instances.
Note
The owner of a paid AMI can confirm if a particular instance was launched using their paid AMI.
Amazon Elastic Compute Cloud User Guide Bills for Paid and Supported AMIs
Important
After you set the product code attribute, it cannot be changed or removed. To associate a product code with your AMI, use the ec2-modify-image-attribute command:
PROMPT> ec2-modify-image-attribute <ami_id> --product-code <product_code>
The <ami_id> is the AMI ID and <product_code> is the product code. The following command associates the ami-2bb65342 AMI with the 774F4FF8 product code.
PROMPT> ec2-modify-image-attribute ami-2bb65342 --product-code 774F4FF8 productCodes ami-2bb65342 productCode 774F4FF8
Important
If you've purchased Amazon EC2 Reserved Instances, you can't use them with supported AMIs. That is, if you associate a product code with one of your AMIs, you don't get the lower price associated with your Reserved Instances when you launch that AMI. You always pay the price that the seller of the support product specified. For more information, see Reserved Instances.
Amazon Elastic Compute Cloud User Guide Create an AMI from an Instance
3.
4.
[Optional] Connect to the instance and customize it however you want. For example, you can install software and applications, copy data, or attach additional EBS volumes. For more information about connecting to an instance, see Connecting to Amazon EC2 Instances (p. 282). In the Navigation pane, click Instances to view a list of your instances. Right-click your running instance and select Create Image (EBS AMI).
Tip
If this option is disabled, your instance isn't an Amazon EBS-backed instance. The Create Image dialog box appears.
5.
Fill in the requested information as follows, and click Yes, Create. a. b. c. A unique name for the image. [Optional] A description of the image (up to 255 characters). By default, Amazon EC2 shuts down the instance, takes snapshots of any attached volumes, creates and registers the AMI, and then reboots the instance. Select No Reboot if you don't want your instance to be shut down.
Warning
If you select the No Reboot option, the file system integrity of the created image can't be guaranteed. d. [Optional] You can modify the root volume, EBS volumes, and instance store volumes as follows: To change the size of the root volume, click Root Volume, fill in the Volume Size field, and click Save. To suppress an EBS volume specified by the block device mapping of the AMI used to launch the instance, click EBS Volumes, go to the volume, and click Delete. To add an EBS volume, click EBS Volumes, fill in the fields (Device, Snapshot, and so on), and click Add. When you then launch an instance from your new AMI, these additional volumes are automatically attached to the instance. Empty volumes must be formatted and mounted. Volumes based on a snapshot must be mounted. To suppress an instance store volume specified by the block device mapping of the AMI used to launch the instance, click Instance Store Volumes, go to the volume, and click Delete.
Amazon Elastic Compute Cloud User Guide Delete an AMI and a Snapshot
To add an instance store volume, click Instance Store Volumes, select the Instance Store and Device, and click Add. When you launch an instance from your new AMI, these additional volumes are automatically initialized and mounted. These volumes don't contain data from the instance store volumes of the running instance from which you based your AMI. For more information, see Root Device Volume (p. 127), Amazon EC2 Instance Store (p. 536), and Block Device Mapping (p. 545)
6.
In the Navigation pane, select AMIs page to view the AMI's status. While the new AMI is being created, its status is pending.
7.
It takes a few minutes for the whole process to finish. After your new AMI's status is available, go to the Snapshots page and view the new snapshot that was created for the new AMI. Any instance you launch from the new AMI uses this snapshot for its root device volume.
8.
Go back to the AMIs page, right-click the image, and select Launch Instance. The launch wizard opens.
9. Walk through the wizard to launch an instance of your new AMI. 10. After your instance's status is running, connect to the instance and verify that any changes you made to the original AMI have persisted. You now have a new AMI and snapshot that you just created. Both continue to incur charges to your account until you stop or delete them.
2.
Amazon Elastic Compute Cloud User Guide Overview of the AMI Creation Process
Creating your own AMI helps you make the most of Amazon EC2. Your AMI becomes the basic unit of deployment; it enables you to rapidly boot new custom instances as you need them. This section gives an overview of your AMI creation options, identifies the tools you need, and walks you through the process. Before you begin this section, you should be familiar with AMI and instance concepts. For more information, see the following sections: Amazon Machine Images (AMI) (p. 22) Amazon EC2 Instances (p. 88) Root Device Storage (p. 7) Amazon Elastic Block Store (p. 484)
Note
This topic describes the process for creating an Amazon EBS-backed Linux AMI. For information about Amazon EBS-backed Windows AMIs, see Creating an Amazon EBS-Backed Windows AMI. For instructions using an instance store-backed AMI, see Creating Instance Store-Backed Linux/UNIX AMIs (p. 38). Topics Creating an Amazon EBS-Backed Linux AMI (p. 36) Special Cases (p. 36) How to Create Amazon EBS-Backed AMIs (p. 37) Converting Amazon EC2 instance store-backed AMIs to EBS-Backed AMIs (p. 38)
Amazon Elastic Compute Cloud User Guide Creating Amazon EBS-Backed Linux AMIs
2.
Important
If you customize your instance with instance store volumes or additional EBS volumes besides the root device, the new AMI contains block device mapping information for those volumes. When you then launch an instance from your new AMI, the instance automatically launches with the additional volumes. 3. When the instance is set up the way you want it, it is best to stop the instance before you create the AMI to ensure data integrity. Use the following steps to stop the instance: a. b. Right-click your running instance and select Stop Instance. When prompted to confirm this, click Yes, Stop Instance.
4.
It takes several minutes for the entire process to complete. If you customized the instance with instance store volumes or additional EBS volumes besides the root device, the new AMI contains block device mapping information for those volumes. When you launch an instance from your new AMI, the instance automatically launches with the additional volumes.The instance store volumes are new and don't contain any data from the instance store volumes of the original instance used to create the AMI. Amazon EC2 powers down the instance before creating the AMI to ensure that everything on the instance is stopped and in a consistent state during the creation process. If you're confident that your instance is in a consistent state appropriate for AMI creation, you can add the --no-reboot flag to ec2-create-image or CreateImage that tells Amazon EC2 not to power down and reboot the instance. With this flag, the instance remains running throughout the AMI creation process. Some file systems, such as xfs, can freeze and unfreeze activity, making it safe to create the image without rebooting the instance.
Special Cases
In some cases, the general tasks in creating Amazon EBS-backed AMIs don't apply: You don't have the original AMI from which to launch instances. In this case, you can create an Amazon EBS-backed AMI by registering a snapshot of a root device. You must own the snapshot and it must be a Linux/UNIX system (this process is not available for Windows instances). For more information about creating an AMI this way, see Creating and Launching an AMI from a Snapshot (p. 280). You have an Amazon EC2 instance store-backed Linux/UNIX AMI. In this case, you can convert the AMI to be backed by Amazon EBS. You cannot convert a Windows AMI backed by instance store. For more information about converting a Linux/UNIX AMI, see Converting Amazon EC2 instance store-backed AMIs to EBS-Backed AMIs (p. 38).
Amazon Elastic Compute Cloud User Guide Creating Amazon EBS-Backed Linux AMIs
For example:
PROMPT> ec2-create-image -n "My AMI" i-eb977f82
2.
If you want to check whether the AMI is ready, use the ec2-describe-images command as follows:
$ ec2-describe-images -o self
Amazon EC2 returns information about the AMI. If the AMI you start with doesn't already have the storage devices you want attached, you can add them by creating EBS volumes or using block device mapping. To create EBS volumes, use ec2-create-volume and ec2-attach-volume. You also can call ec2-run-instances with block device mapping information for the devices you want to add. For more information about block device mapping, see Block Device Mapping (p. 545).
API
To create an Amazon EBS-backed AMI, construct the following Query request to create an image:
https://ec2.amazonaws.com/ ?Action=CreateImage &InstanceId=instance_id &Name=My_Ami &AUTHPARAMS
In the following example response, Amazon EC2 creates the image and returns its AMI ID.
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
AMI creation can take time. You can check whether the AMI is ready using DescribeImages. If the AMI you start with doesn't already have the storage devices you want attached, you can add them by creating EBS volumes or using block device mapping. To create EBS volumes, use CreateVolume and AttachVolume. You also can call RunInstances with block device mapping information for the devices you want to add. For more information about block device mapping, see Block Device Mapping (p. 545).
Important
You can't convert an instance store-backed Windows AMI to an EBS-backed Windows AMI. You must start with a public EBS-backed Windows AMI, modify it to meet your specifications, and then create an image from it. For information, see Creating Amazon EBS-Backed AMIs Using the Console (p. 32). The following table describes the conversion process.
How to convert a Linux/UNIX Amazon EC2 instance store-backed AMI to an EBS-backed AMI
1 2 3 Copy the AMI's root device information to an Amazon EBS volume. For more information, see the related task list in Amazon EC2 Root Device Storage Usage Scenarios (p. 129) Create a snapshot of that volume. For more information, see Creating an Amazon EBS Snapshot (p. 522). Register the image with a block device mapping that maps the root device name of your choice to the snapshot you just created. For an example, see Block Device Mapping (p. 545).
You might find it useful to refer to available blog posts that discuss conversion. The following are two example blogs; AWS, however, takes no responsibility for the completeness or accuracy of the content: http://www.elastician.com/2009/12/creating-ebs-backed-ami-from-s3-backed.html http://coderslike.us/2009/12/07/amazon-ec2-boot-from-ebs-and-ami-conversion/
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
For Linux/UNIX systems, you have two common ways to prepare Amazon EC2 instance store-backed AMIs. The easiest method (A) involves launching an existing public AMI and modifying it according to your requirements. For more information, see Creating an Instance Store-Backed AMI From an Existing AMI (p. 40). Another approach (B) is to build a fresh installation either on a stand-alone machine or on an empty file system mounted by loopback. The process entails building an operating system installation from scratch. After you've built the installation package to your satisfaction, you must bundle it using the AMI tool for bundling volumes and register it using the command line tool for registering images. For information, see Creating an Instance Store-Backed AMI From a Loopback (p. 44). The following diagram shows the general tasks in creating Amazon EC2 instance store-backed Linux/UNIX AMIs.
This section discusses the steps for creating AMIs from an existing file and from a loopback, and some basics about the AMI tools.
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
For information about installing the AMI tools, go to Amazon EC2 AMI Tools.
2.
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
4 5
Upload a Bundled AMI (p. 43) Register the AMI (p. 43)
Customize an Instance
Customizing an instance involves the following series of steps: 1. Selecting an AMI from available AMIs. 2. Launching an instance from the AMI you selected. 3. Making changes to (thus, customizing) the instance, such as altering the Linux configuration, adding software, and configuring web applications. For more information, see Launching Amazon EC2 Instances (p. 274). After you've launched an instance according to your specifications, proceed to the next steps to create a new AMI using the customized instance.
Where, Parameter
keypair_name private_keyfile certificate_file username
Description The name of your key pair. The file that contains the private key. The file that contains the certificate. The login name you use to log in to your instance.
API Version 2013-02-01 41
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
Parameter
dns_location
Description The DNS location of the instance within Amazon EC2. The directory where your instance store is mounted.
scp displays the names of the files copied and some performance statistics. The following is an example of a fully specified scp command using the Amazon Linux AMI.
$ scp -i gsg-keypair pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem cert-HKZYKTAIG2ECMXY IBH3HXV4ZBEXAMPLE.pem ec2-user@ec2-67-202-51-223.compute-1.amazon aws.com:/tmp/cert pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem 100% 717 0.7KB/s 00:00 cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem 100% 685 0.7KB/s 00:00
<private_keyfile> is the file that contains the private key <certificate_file> is the file that contains the certificate <user_id> is the ID associated with your AWS account. This is your AWS account ID without dashes. It consists of 12 to 15 characters, and it's not the same as your access key ID. For information about viewing your AWS account ID, see Viewing Your Account ID (p. 445) <cert_location> is the directory that contains the private key and certificate files, which must be excluded from the bundle.
Note
Be sure to disable SELinux when running ec2-bundle-vol. The following command bundles the local machine root file system.
# ec2-bundle-vol -e /tmp/cert -k pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem -c cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem -u 111122223333 Please specify a value for arch [x86_64]: Copying / into the image file /tmp/image... Excluding: /sys ... /tmp/cert
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
... 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.00172 s, 610 MB/s mke2fs 1.42.3 (14-May-2012) Bundling image file... Splitting /tmp/image.tar.gz.enc... Created image.part.00 Created image.part.01 ... Created image.part.NN Generating digests for each part... Digests generated. Creating bundle manifest... ec2-bundle-vol complete.
Important
The specified Amazon S3 bucket must exist, and it must have been created in the same region that the instance being uploaded was created in.
<your-s3-bucket> is the Amazon S3 bucket that the bundle will be uploaded to.You can also upload the bundle to a subfolder of the bucket, such as my-awsbucket/uploaded-images/image-1. If the subfolder does not exist, it will be created. <manifest_path> is the full path to the manifest file (for example, /tmp/image.manifest.xml). The manifest file will reside in the destination directory that was specified in the ec2-bundle-vol command. <access_key> is your AWS access key ID. <secret_key> is your AWS secret key. The AMI manifest file and all image parts are uploaded to Amazon S3. The manifest file is encrypted with the Amazon EC2 public key before being uploaded.
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
Important
The capitalization of the bucket name and path in <your-s3-bucket>/<path> must match exactly what was passed in the ec2-upload-bundle command. This command registers the AMI in the default region. To specify a different region, set the EC2_URL environment variable, or use the --region option with the ec2-register command. Amazon EC2 returns an AMI identifier, the value next to the IMAGE tag (ami-2bb65342 in the example), that you can use to run instances.
Note
This method works only with AMIs that use instance stores for their root devices. This method is not applicable for AMIs backed by Amazon EBS.
2 3 4
Bundle the Loopback File Image (p. 50) Upload a Bundled AMI (p. 51) Register the AMI (p. 52)
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
The <image_name> is the name of the image file you are creating and <size> is the size of the file in megabytes.
Example
The following example creates a 1 GB file (1024*1 MB).
# dd if=/dev/zero of=my-image.fs bs=1M count=1024 1024+0 records in 1024+0 records out
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
Example
The following example creates an ext3 file system.
# mke2fs -F -j my-image.fs mke2fs 1.38 (30-Jun-2005) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 131072 inodes, 262144 blocks 13107 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=268435456 8 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 24 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
The <image_mountpoint> is the location where the image will be mounted. 2. Mount the file system image:
# mount -o loop <image_name> <image_mountpoint>
The <image_name> is the name of the image file and <image_mountpoint> is the mount location.
Example
The following commands create and mount the my-image.fs image file.
# mkdir /mnt/ec2-fs # mount -o loop my-image.fs /mnt/ec2-fs
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
The <image_mountpoint> is the mount location. 2. Create the fstab file within the /etc directory and add the following:
/dev/sda1 none none none none / /dev/pts /dev/shm /proc /sys ext3 devpts tmpfs proc sysfs defaults gid=5,mode=620 defaults defaults defaults 1 0 0 0 0 1 0 0 0 0
3.
Create a temporary YUM configuration file (e.g., yum-xen.conf) and add the following content.
[main] cachedir=/var/cache/yum debuglevel=2 logfile=/var/log/yum.log exclude=*-debuginfo gpgcheck=0 obsoletes=1 reposdir=/dev/null [base] name=Fedora Core 4 - $basearch - Base mirrorlist=http://fedora.redhat.com/download/mirrors/fedora-core-$releasever enabled=1 [updates-released] name=Fedora Core 4 - $basearch - Released Updates mirrorlist=http://fedora.redhat.com/download/mirrors/updates-releasedfc$releasever enabled=1
4.
This step ensures that all the required basic packages and utilities are installed. You can locate this file anywhere on your main file system (not on your loopback file system) and is used only during installation. Enter the following:
# mkdir <image_mountpoint>/proc # mount -t proc none <image_mountpoint>/proc
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
The <image_mountpoint> is the mount location. A groupadd utility bug in the shadow-utils package (versions prior to 4.0.7-7) requires you to mount the new proc file system manually with the preceding command.
Example
These commands create the /dev directory and populate it with a minimal set of devices:
# mkdir /mnt/ec2-fs/dev # /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x console MAKEDEV: mkdir: File exists MAKEDEV: mkdir: File exists MAKEDEV: mkdir: File exists # /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x null MAKEDEV: mkdir: File exists MAKEDEV: mkdir: File exists MAKEDEV: mkdir: File exists # /sbin/MAKEDEV -d /mnt/ec2-fs/dev -x zero MAKEDEV: mkdir: File exists MAKEDEV: mkdir: File exists MAKEDEV: mkdir: File exists
The <yum_configuration_file> is the name of the YUM configuration file and <image_mountpoint> is the mount location. You now have a base installation, which you can configure for operation inside Amazon EC2 and customize for your use.
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
Example
This example installs the operating system at the /mnt/ec2-fs mount point using the yum-xen.conf YUM configuration file.
# yum -c yum-xen.conf --installroot=/mnt/ec2-fs -y groupinstall Base Setting up Group Process Setting up repositories base 100% |=========================| 1.1 kB 00:00 updates-released 100% |=========================| 1.1 kB 00:00 comps.xml 100% |=========================| 693 kB 00:00 comps.xml 100% |=========================| 693 kB 00:00 Setting up repositories Reading repository metadata in from local files primary.xml.gz 100% |=========================| 824 kB 00:00 base : ################################################## 2772/2772 Added 2772 new packages, deleted 0 old in 15.32 seconds primary.xml.gz 100% |=========================| 824 kB 00:00 updates-re: ################################################## 2772/2772 Added 2772 new packages, deleted 0 old in 10.74 seconds ... Complete!
Note
The Amazon EC2 DHCP server ignores hostname requests. If you set DHCP_HOSTNAME, the local hostname will be set on the instance but not externally. Additionally, the local hostname will be the same for all instances of the AMI, which might be confusing. 2. Verify that the following line appears in the /mnt/ec2-fs/etc/sysconfig/network file so that networking starts:
NETWORKING=yes
3.
Add the following lines to /mnt/ec2-fs/etc/fstab so that local disk storage on /dev/sda2 and swap space on /dev/sda3 are mounted at system startup:
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
/dev/sda2 /dev/sda3
/mnt swap
ext3 swap
defaults defaults
0 0 0 0
Note
The /dev/sda2 and /dev/sda3 storage locations only apply to small instances. For more information on instance storage, see Amazon EC2 Instance Storage (p. 536). 4. Allocate appropriate system run levels so that all your required services start at system startup. For example, to enable the service my-service on multiuser and networked run levels, enter the following commands:
# chroot /mnt/ec2-fs /bin/sh # chkconfig --level 345 my-service on # exit
Your new installation is successfully installed and configured to operate in the Amazon EC2 environment. 5. Enter the following commands to umount the image:
# umount <image_mountpoint>/proc # umount -d <image_mountpoint>
Example
The following example unmounts the installation from the /mnt/ec2-fs mount point.
# umount /mnt/ec2-fs/proc # umount -d /mnt/ec2-fs
The <image_name> is the name of the image file, <private_keyfile> is the file that contains the private key, <certificate_file> is the file that contains the certificate, and <user_id> is the ID associated with your AWS account.
Note
The user ID is your AWS account ID without dashes. It consists of 12 to 15 characters, and it's not the same as your Access Key ID. For information about viewing your account ID, see Viewing Your Account ID (p. 445).
Amazon Elastic Compute Cloud User Guide Creating Instance Store-Backed Linux/UNIX AMIs
Example
The ec2-bundle-image command bundles an image created in a loopback file.
# ec2-bundle-image -k pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem -c cert-HKZYK TAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem -u 111122223333 -i image.img -d bundled/ -p fred -r x86_64 Please specify a value for arch [i386]: Bundling image file... Splitting bundled/fred.gz.crypt... Created fred.part.00 Created fred.part.01 Created fred.part.02 Created fred.part.03 Created fred.part.04 Created fred.part.05 Created fred.part.06 Created fred.part.07 Created fred.part.08 Created fred.part.09 Created fred.part.10 Created fred.part.11 Created fred.part.12 Created fred.part.13 Created fred.part.14 Generating digests for each part... Digests generated. Creating bundle manifest... ec2-bundle-image complete.
Important
The specified Amazon S3 bucket must exist, and it must have been created in the same region that the instance being uploaded was created in.
<your-s3-bucket> is the Amazon S3 bucket that the bundle will be uploaded to.You can also upload the bundle to a subfolder of the bucket, such as my-awsbucket/uploaded-images/image-1. If the subfolder does not exist, it will be created. <manifest_path> is the full path to the manifest file (for example, /tmp/image.manifest.xml). The manifest file will reside in the destination directory that was specified in the ec2-bundle-vol command. <access_key> is your AWS access key ID.
API Version 2013-02-01 51
<secret_key> is your AWS secret key. The AMI manifest file and all image parts are uploaded to Amazon S3. The manifest file is encrypted with the Amazon EC2 public key before being uploaded.
Important
The capitalization of the bucket name and path in <your-s3-bucket>/<path> must match exactly what was passed in the ec2-upload-bundle command. This command registers the AMI in the default region. To specify a different region, set the EC2_URL environment variable, or use the --region option with the ec2-register command. Amazon EC2 returns an AMI identifier, the value next to the IMAGE tag (ami-2bb65342 in the example), that you can use to run instances.
However, other details of creating, submitting AMIs to the AWS Marketplace are different, and are discussed in more detail in the AWS Marketplace Seller's Guide.
Important
Amazon DevPay does not support Amazon EBS-backed AMIs. All paid AMIs must be backed by Amazon instance store.
Amazon DevPay
A paid AMI is an AMI that you sell to other Amazon EC2 users. They pay you according to the price you set. To be able to create a paid AMI, you use Amazon DevPay.
Important
Amazon DevPay does not support Amazon EBS-backed AMIs. All paid AMIs must be backed by Amazon instance store. What is Amazon DevPay? Amazon DevPay is a billing and account management service that enables you to get paid for an AMI you create and that other Amazon EC2 users use. Amazon DevPay creates and manages the order pipeline and billing system for you. Your customers sign up for your AMI, and Amazon DevPay automatically meters their usage of Amazon EC2, bills them based on the pricing you set, and collects their payments. DevPay offers the following: You can charge customers for your Amazon EC2 instance store-backed AMI; the charges can include recurring charges based on the customer's usage Amazon EC2, a fixed one-time charge, and a recurring monthly charge. Your customers can easily sign up and pay for your Amazon EC2 instance store-backed AMI with their trusted Amazon.com accounts. Your customers are authenticated, thus ensuring they have access only to what they should. If your customers don't pay their bills, DevPay turns off their access to your AMI for you. Amazon Payments handles payment processing.
2 3 4
For more information about Amazon DevPay, refer to the Amazon DevPay Developer Guide.
Important
The discounts you get with Amazon EC2 Reserved Instances don't apply to Amazon DevPay products. That is, if you purchase Reserved Instances, you don't get the lower price associated with them when your customers launch your paid or supported AMIs. Also, if your customers purchase Reserved Instances, when they use your paid or supported AMIs, they continue to pay the price you specified for the use of your paid or supported AMIs. For more information about Reserved Instances, see Reserved Instances (p. 212). You can also use Amazon EC2 and Amazon DevPay together with a supported AMI. For more information about supported AMIs, see Supported AMIs (p. 59). The following figure and table summarize the basic flow for creating and using paid AMIs.
Note
Detailed information about most of the following steps is provided in the Amazon DevPay Developer Guide.
You register a product with Amazon DevPay. For more information, see Product Registration (p. 56). As part of this process, you provide a product description, product pricing, etc. This registration process creates a product code for the product and a URL where customers can sign up to use the product (called the purchase URL).
Note
You cannot register an AMI that already has an AWS Marketplace code associated with it. 3 You use an Amazon EC2 command or API call to associate the product code with your Amazon EC2 instance store-backed AMI. For more information, see Associating a Product Code with an AMI (p. 57). This makes the AMI a paid AMI. 4 You use an Amazon EC2 command or API call to share the Amazon EC2 instance store-backed AMI with select customers or the public. For more information, see Sharing Your Paid AMI (p. 58).
Note
Even if you share a paid AMI and it has a product code, no one can use the AMI until they sign up for it (see the following steps). 5 You make your paid AMI available for sale. To do this, you make the aforementioned purchase URL available. You can advertise your paid AMI in the Solutions Catalog on the AWS Developer Connection site and on the Amazon Machine Images (AMIs) page on the AWS Resource Center. 6 Customers use the purchase URL you provide to sign up for and purchase your product. If they're not already signed up for Amazon EC2, they'll be prompted to sign up. They purchase your product with their Amazon.com accounts. They must have the credentials needed to launch Amazon EC2 instances. At this point, they have the AMI ID (from step 5). 7 Customers then launch an Amazon EC2 instance specifying the AMI ID. Because you associated the shared AMI with the product code, the customers are charged at the rate you set. For more information, see Paid AMIs (p. 30).
Note
You can associate your DevPay product code with more than one Amazon EC2 instance store-backed AMI. However, a single AMI can be associated with only one product code. If you plan to sell multiple AMIs, you could sell them all under a single product code, or different product codes (by registering multiple DevPay products). For information about why you might choose a single product code or multiple product codes, go to If You Have Multiple AMIs to Sell in the Amazon DevPay Developer Guide. Each customer's bill for the AMI is displayed on their Application Billing page, which shows the activity for DevPay products. Also, at any time, you can confirm the customer is still currently subscribed to your product. For more information, refer to the Amazon DevPay Developer Guide.
Note
In the preceding process, you associate your product code with your own Amazon EC2 instance store-backed AMI and sell the AMI as a DevPay product. There's another scenario for using DevPay with Amazon EC2 in which you sell software or a service to EC2 users and let them
associate your product code with their own Amazon EC2 instance store-backed AMIs. For more information, see Supported AMIs (p. 59).
Linux/UNIX AMIs
If you give the customer root access to your paid Linux/UNIX AMI, the customer can rebundle it (for more information, see Creating Your Own AMIs (p. 34)). If your customer uses AWS tools to rebundle the AMI, the rebundled AMI inherits the product code. When launching instances of the rebundled AMI, the customer is still billed for usage based on your price. However, if the customer doesn't use the AWS tools when rebundling, the rebundled AMI won't inherit the product code, and the customer will pay normal Amazon EC2 rates and not your price. Also, a customer with root access could find some other way to remove the product code from the AMI. When a customer contacts you for support for a paid AMI, you can confirm your product code is associated with the AMI and the customer's instance is currently running the AMI. For more information, go to Confirming an Instance Is Running with a Product Code (p. 58). If you have software installed on the AMI, the software can retrieve the instance metadata to determine if the product code is associated with the instance. For more information, see Getting the Product Code from Within an Instance (p. 59). Keep in mind that the preceding methods for confirming the association of the product code with the instance are not foolproof because a customer with root access to the instance could return false information indicating the product code is associated with the instance.
Windows AMIs
When you associate a product code with a Windows AMI, the association is permanent. Therefore, we recommend you keep a separate, base copy of the AMI that has no product code associated with it. Anyone who purchases a Windows AMI can rebundle it (for more information, see Creating Your Own AMIs (p. 34)). The product code is automatically transferred to the rebundled AMI. When EC2 users launch instances of the rebundled AMI, they pay the rates you set when you registered your DevPay product. In turn, you're charged for the EC2 costs they incur.
Product Registration
You must register a product with Amazon DevPay. The product can cover a single Amazon EC2 instance store-backed AMI that you want to sell or multiple Amazon EC2 instance store-backed AMIs. During registration, you provide product information such as pricing, and you receive information you need to sell your product.
Important
The Amazon DevPay Developer Guide covers the procedure for registering your product with Amazon DevPay. Before you register your product, we recommend you read the information in that guide about how to set your AMI's price and how billing for Amazon DevPay products works. You provide the following information during registration: Company name Product name Product description (as you want your customers to see it) Redirect URL (the page you want customers to see after they have purchased the product)
API Version 2013-02-01 56
Any terms and conditions you want displayed (optional) Contact e-mail address and telephone number (to be used by AWS and not displayed to customers) Contact e-mail or URL (to be displayed to customers) The specific Regions, environments, and instance types the product covers Pricing for use of the product (you can set different prices based on Region, environment, and instance type) The information you display at the redirect URL should give information about the AMI. Registration provides you with the following information: Product code, which contains a product code and type Product token Purchase URL You need the product code and purchase URL to integrate your product with DevPay as described in Summary of How Paid AMIs Work with Amazon DevPay (p. 54) and Supported AMIs (p. 59). You need the product token if you're going to set up your system to later verify whether a customer is still subscribed to your product. For more information, refer to the Amazon DevPay Developer Guide.
Note
AWS must approve your product after you register it. The approval process typically takes one business day.
You can't change or remove the productCodes attribute after you've set it. If you want to use the same image without the product code or associate a different product code with the image, you must reregister the image to obtain a new AMI ID. You can then use that AMI without a product code or associate the new product code with the AMI ID.
Example
The following example associates the ami-2bb65342 AMI with the 774F4FF8 product code.
PROMPT> ec2-modify-image-attribute ami-2bb65342 --product-code 774F4FF8 ami-2bb65342 productCode [devpay: 774F4FF8]
productCodes
This example verifies that the product code is associated with the AMI.
PROMPT> ec2-describe-image-attribute ami-2bb65342 --product-code ami-2bb65342 productCode [devpay: 774F4FF8]
productCodes
The <ami_id> is the AMI ID. Even though you've shared the AMI, no one can use it until they sign up for your product by going to the purchase URL. Once customers sign up, any instances of the paid AMI they launch will be billed at the rate you specified during product registration.
Example
The following example shares the ami-2bb65342 AMI with the public.
PROMPT> ec2-modify-image-attribute ami-2bb65342 --launch-permission -a all ami-2bb65342 ADD group all
launchPermission
Note
You must be the owner of the product code to successfully call ec2-confirm-product-instance with that product code. Because your customers don't own the product code, they should describe their instances to confirm their instances are running with your product code.
To confirm an instance is running an AMI associated with your product code (DevPay or AWS Marketplace)
Enter the following command:
PROMPT> ec2-confirm-product-instance <product_code> -i <instance>
The <product_code> is the product code and <instance> is the instance. If the AMI is associated with the product code, true is returned with the AMI owner's account ID. Otherwise, false is returned.
Example
The following example confirms whether the i-10a64379 instance is running the 6883959E product code.
PROMPT> ec2-confirm-product-instance 6883959E -i i-10a64379
Supported AMIs
Supported AMIs are different from paid AMIs. With a supported AMI, you charge for software or a service you provide that customers use with their own AMIs. The main difference between a paid AMI and a supported AMI is how the AMI is associated with a product code: Paid AMIYou associate your own product code with your own AMI Supported AMIOther EC2 users associate your product code with their own AMIs
Important
If your customers purchase Reserved Instances, they don't get the Reserved Instance price discount with supported AMIs. That is, if they associate your product code with their AMIs, they don't get the lower price associated with their Reserved Instances when they launch those AMIs. They always pay the price that you specified for your DevPay product. For more information, see Reserved Instances (p. 212). The following figure and table summarizes the flow for creating and using supported AMIs.
API Version 2013-02-01 59
Note
Amazon EC2 prevents your customers (but not you as the product code owner) from associating your product code with AMI types the product isn't configured for. For example, if the product is configured only for Linux/UNIX AMIs, your customers can't associate the product code with Windows AMIs. Also, Amazon EC2 prevents your customers from launching specific instance types your product isn't configured for. For more information about product configuration, go to Your Product's Configuration and Price in the Amazon DevPay Developer Guide. Each customer's bill for the AMI is displayed on their Application Billing page, which shows the activity for DevPay products. For more information, refer to the Amazon DevPay Developer Guide. When a customer contacts you for support for an AMI, you can confirm your product code is associated with the AMI and the customer's instance is currently running the AMI. For more information, see Confirming an Instance Is Running with a Product Code (p. 58).
Note
These guidelines are written for Fedora distributions, but the principles apply to any AMI. You might need to modify the provided examples for other distributions. For other distributions, review their documentation or search the AWS forums in case someone else has done it already.
Note
When deciding which software to automatically update, consider the amount of WAN traffic that the update will generate (your users will be charged for it) and the risk of the update breaking other software on the AMI.
Note
The preceding procedure applies to Fedora distributions. For other distributions: On most Red Hat systems, add these steps to your /etc/rc.d/rc.local script. On Gentoo systems, add them to /etc/conf.d/local.local. On Ubuntu systems, add them to /etc/rc.local. On Debian, you might need to create a start up script in /etc/init.d and use update-rc.d <scriptname> defaults 99 (where <scriptname> is the name of the script you created) and add the steps to this script.
2.
The location of this configuration file might differ for your distribution, or if you are not running OpenSSH. If this is the case, consult the relevant documentation. 3. To randomize the root password, add the following to your boot process:
if [ -f "/root/firstrun" ] ; then dd if=/dev/urandom count=50|md5sum|passwd --stdin root
Note
This step assumes that a /root/firstrun file is bundled with the image. If the file was not created, the root password will never be randomized and will be set to the default.
Note
If you are using a distribution other than Fedora, you might need to consult the documentation that accompanied the distribution.
Important
If you forget to remove the existing SSH host key pairs from your public AMI, our routine auditing process will notify you and all customers running instances of your AMI of the potential security risk. After a short grace period, we will mark the AMI private.
key if [ $? -eq 0 ] ; then cat /tmp/my-key >> /root/.ssh/authorized_keys chmod 700 /root/.ssh/authorized_keys rm /tmp/my-key fi
This can be applied to any user account; you do not need to restrict it to root.
Note
Rebundling an instance based on this image includes the key with which it was launched. To prevent the key's inclusion, you must clear out (or delete) the authorized_keys file or exclude this file from rebundling.
Note
The location of this configuration file can differ for your distribution or if you are not running OpenSSH. If this is the case, consult the relevant documentation.
Identify Yourself
Currently, there is no easy way to know who provided a shared AMI because each AMI is represented by an account ID. We recommend that you post a description of your AMI, and the AMI ID, in the Amazon EC2 developer forum. This provides a convenient central location for users who are interested in trying new shared AMIs. You can also post the AMI to the Amazon Machine Images (AMIs) page.
Protect Yourself
The previous sections described how to make your shared AMIs safe, secure, and usable for the users who launch them. This section describes guidelines to protect yourself from the users of your AMI. We recommend against storing sensitive data or software on any AMI that you share. Users who launch a shared AMI might be able to rebundle it and register it as their own. Follow these guidelines to help you to avoid some easily overlooked security risks: Always delete the shell history before bundling. If you attempt more than one bundle upload in the same image, the shell history contains your secret access key.
Bundling a running instance requires your private key and X.509 certificate. Put these and other credentials in a location that is not bundled (such as the instance store). Exclude the ssh authorized keys when bundling the image. The Amazon public images store the public key used to launch an instance with its ssh authorized keys file.
Note
Unfortunately, it is not possible for this list of guidelines to be exhaustive. Build your shared AMIs carefully and take time to consider where you might expose sensitive data.
Sharing AMIs
Amazon EC2 enables you to share your AMIs with other AWS accounts. This section describes how to share AMIs using the Amazon EC2 management console and the command line tools.
Note
Before proceeding, make sure to read the security considerations of sharing AMIs in the Protecting a Shared AMI (Linux/UNIX) (p. 61) section.
4. In the Set AMI Permissions box, verify that Private is selected. 5. Under Add Launch Permission, type the AWS Account Number of the user with whom you want to share the AMI in the AWS Account Number 1 box. To share this AMI with multiple users, click add additional user and type the AWS Account Number(s) of the user(s) with whom you want to share the AMI. 6. To allow create volume permissions for snapshots, check Add create volume permissions for these account numbers to the following associated snapshots. 7. Select Yes, Edit.
API Version 2013-02-01 65
Note
You are not billed when your AMI is launched by other AWS accounts. The accounts launching the AMI are billed.
Note
Images with an AWS Marketplace product code cannot be made public.
This will not affect any explicit launch permissions for the AMI or any running instances of the AMI.
Example
This example makes the ami-2bb65342 AMI public.
PROMPT> ec2-modify-image-attribute ami-2bb65342 --launch-permission -a all launchPermission ami-2bb65342 ADD group all
This example removes the all group from the permissions of the ami-2bb65342 AMI, making it private.
PROMPT> ec2-modify-image-attribute ami-2bb65342 -l -r all launchPermission ami-2bb65342 REMOVE group all
The <ami_id> is the ID of the AMI and <user_id> is the account ID, without hyphens.
The <ami_id> is the ID of the AMI and <user_id> is the account ID, without hyphens.
Note
The AMI owner always has rights to the AMI and is unaffected by this command.
Example
The following example grants launch permissions to the AWS account with ID 111122223333 for the ami-2bb65342 AMI:
PROMPT> ec2-modify-image-attribute ami-2bb65342 -l -a 111122223333 launchPermission ami-2bb65342 ADD userId 111122223333
The following example removes launch permissions from the AWS account with ID 111122223333 for the ami-2bb65342 AMI:
PROMPT> ec2-modify-image-attribute ami-2bb65342 -l -r 111122223333 launchPermission ami-2bb65342 REMOVE userId 111122223333
The following example removes all public and explicit launch permissions from the ami-2bb65342 AMI:
PROMPT> ec2-reset-image-attribute ami-2bb65342 -l launchPermission ami-2bb65342 RESET
2.
If you want to, you can paste the following information into the document. You must be in HTML edit mode.
<strong>AMI ID: </strong>[ami-id]<br /> <strong>AMI Manifest: </strong>[myawsbucket/image.manifest.xml]<br /> <h2>About this &AMI;</h2> <ul> <li>Published by [Publisher] (<a href="http://www.example.com">[ht tp://www.example.com]</a>).<br /> </li> <li>[Key Features] <br />
</li> <li>[Description]</li> <li>This image contains the following daemons / services: <ul> <li>[Daemon 1]</li> <li>[Daemon 2]</li> </ul> </li> </ul> <h2><strong>What's New?</strong></h2>The following changes were made on [Date].<br /> <ul> <li>[Release Notes 1]</li> </ul> <span style="font-size: x-small; font-family: courier new,couri er"> - [Note 1]</span><br /> <span style="font-size: x-small; font-family: courier new,couri er"> - [Note 2]</span><br /> <span style="font-size: x-small; font-family: courier new,couri er"> - [Note 3]</span><br /> <!--<ul>-->
Copying AMIs
With EC2 AMI copy, you can easily copy the Amazon Machine Images (AMIs) you own to other AWS regions and scale your applications to take advantage of AWS's geographically diverse regions. EC2 AMI copy provides the following benefits: Consistent global deployment:You can copy an AMI from one region to another, enabling you to launch consistent instances based from the same AMI into different regions. Scalability: You can more easily design and build world-scale applications that meet the needs of your users, regardless of their location. Performance: You can increase performance by distributing your application, as well as locating critical components of your application in closer proximity to your users. You can also take advantage of region-specific features, such as instance types or other AWS services. High availability: You can design and deploy applications across AWS regions, to increase availability. EC2 AMI copy enables you to copy an AMI to as many regions as you like from the AWS Management Console, the Amazon EC2 CLI, or the Amazon EC2 API. EC2 AMI copy is available for Amazon EBS-backed AMIs as well as instance-store-backed AMIs, and is operating-system-agnostic. Each copy of an AMI results in a new AMI with its own unique AMI ID. Any changes made to the source AMI during or after a copy are not propagated to the new AMI as part of the AMI copy process; you must recopy the AMI to the destination regions to copy the changes made to the source AMI.
Note
Permissions and user-defined tags applied to the source AMI are not copied to the new AMIs as part of the AMI copy process. After the copy is complete, you may apply any permissions and user-defined tags to the new AMIs.
Amazon Elastic Compute Cloud User Guide Copying an Amazon EC2 AMI
4.
In the AMI Copy wizard, choose the following: Destination region: Select the region to which you want to copy the AMI. Name: Type a name for the new AMI. Description: By default, the description includes information about the source AMI so that you can identify a copy from the original. You can change this description as necessary.
5.
Amazon Elastic Compute Cloud User Guide Stopping the AMI copy operation
6.
The Copy AMI confirmation dialog box appears, notifying you that the copy operation has been initiated. The new AMI ID is provided. Click Close.
To view the progress of the copy operation later, switch the Amazon EC2 console to the destination region, and then refresh the AMI pane. The copy operation is complete when the new AMI's status displays available.
API
To copy an AMI using the API You can create a copy of an Amazon EC2 AMI using the API by completing the steps in the CopyImage topic in the EC2 API Reference. This action connects to the destination region and "pulls" copies of the source AMI to that destination region.
You can stop the AMI copy operation using the CLI by completing the instructions in the ec2-deregister topic in the EC2 Command Line Reference. This action stops the copy operation and deregisters the new AMI in the destination region.
API
To stop the AMI copy operation using the API You can stop the AMI copy operation using the API by completing the steps in the DeregisterImage topic in the EC2 API Reference. This action stops the copy operation and deregisters the new AMI in the destination region.
Q: Which AKI and ARI will the new AMI use? EC2 AMI copy tries to find matching AKIs and ARIs for the new AMI in the selected destination region. If no suitable AKI or ARI can be found, then the AMI is not copied. If you are using the AKIs and ARIs recommended by Amazon, the copy operation registers the AMI with the appropriate AKI and ARI in the destination region. For AMIs using a AKI or ARI not provided by Amazon, you must ensure the existence of those ARIs or AKIs in the destination region, as well as ensuring that they maintain the same name and description. The copy operation then registers the new AMI with the equivalent destination ARI and AKI. Q: Are copy requests submitted to the source or the destination region endpoint? Calls to request a copy of an AMI from the CLI or API are submitted to and initiated from the destination region endpoint. Q: What types of AMIs and operating systems does EC2 AMI copy support? EC2 AMI copy works with all AMIs and operating systems supported by Amazon EC2. How much does EC2 AMI copy cost? There are no charges for EC2 AMI copy. However, standard storage and data transfer rates apply. Q: Will EC2 AMI copy cost more for Windows AMIs? No. Copying Windows AMIs is free, just like copying Linux AMIs. Currently, differential rates only apply to running instances and reflect the increased cost of running a Windows license. A Windows AMI that is the same size as a Linux AMI and that uses the same backing store (EBS or instance) will result in the same storage and bandwidth usage charges after the copy is complete.
Amazon Elastic Compute Cloud User Guide Finding the Amazon Linux AMI
Support (p. 80) Enabling Your Own Linux Kernels (p. 80)
The image_name, image_version, and image_arch items come from the build recipe that Amazon used to construct the image. The image_stamp is simply a unique random hex value generated during image creation. The image_date item is in YYYYMMDDhhmmss format, and is the UTC time of image creation. The recipe_name and recipe_id refer to the name and ID of the build recipe Amazon used to construct the image, which identifies the current running version of the Amazon Linux AMI. This file will not change as you install updates from the yum repository. Amazon linux AMIs contain a /etc/system-release file that specifies the current release that is installed. This file is updated through yum and is part of the system-release rpm. Following is an example of a /etc/system-release file:
Amazon Elastic Compute Cloud User Guide Included AWS Command Line Tools
An Amazon Linux AMI also contains a machine readable version of the /etc/system-release file found in /etc/system-release-cpe and follows the CPE specification from MITRE (CPE).
To simplify the configuration of these tools, a simple script has been included to prepare AWS_CREDENTIAL_FILE, JAVA_HOME, AWS_PATH, PATH, and product-specific environment variables after a credential file has been installed. Also, to allow the installation of multiple versions of the API and AMI tools, we have placed symlinks to the desired versions of these tools in /opt/aws, as described here: /opt/aws/binSymlink farm to /bin directories in each of the installed tools directories. /opt/aws/{apitools|amitools}Products are installed in directories of the form [name]-version and symlink [name] attached to the most recently installed version. /opt/aws/{apitools|amitools}/[name]/environment.shUsed by /etc/profile.d/aws-apitools-common.sh to set product-specific environment variables (EC2_HOME, etc.).
cloud-init
The cloud-init package is an open source application built by Canonical that is used to bootstrap Linux images in a cloud computing environment, such as Amazon EC2. The Amazon Linux AMI contains a customized version of cloud-init. It enables you to specify actions that should happen to your instance at boot time. You can pass desired actions to cloud-init through the user data fields when launching an instance. This means you can use common AMIs for many use cases and configure them dynamically at startup. The Amazon Linux AMI also uses cloud-init to perform initial configuration of the ec2-user account. For more information about cloud-init, go to https://help.ubuntu.com/community/CloudInit.
The Amazon Linux AMIs use the following cloud-init actions (configurable in /etc/sysconfig/cloudinit): action: INIT (always runs) Setting a default locale. Setting the hostname. Parsing and handling user data. action: CONFIG_SSH Generating host private SSHkeys. Adding user's public SSHkeys to .ssh/authorized_keys for easy login and administration. action: PACKAGE_SETUP Preparing yum repo. Handles package actions defined in user data. action: RUNCMD Runs a shell command. action: RUN_USER_SCRIPTS Executes user scripts found in user data. action: CONFIG_MOUNTS Mounts ephemeral drives. action: CONFIG_LOCALE Sets the locale in the locale config file according to user data.
This content is cloud-config data. See the examples for a commented example of supported config formats. Cloud Boothook Begins with "#cloud-boothook" or "Content-Type: text/cloud-boothook". This content is boothook data. It is stored in a file under /var/lib/cloud and then executed immediately. This is the earliest "hook" available. Note that there is no mechanism provided for running it only once. The boothook must take care of this itself. It is provided with the instance ID in the environment variable INSTANCE_ID. Use this variable to provide a once-per-instance set of boothook data.
Repository Configuration
Beginning with the 2011.09 release of the Amazon Linux AMI, Amazon Linux AMIs are treated as snapshots in time, with a repository and update structure that always gives you the latest packages when you run yum update -y. The repository structure is configured to deliver a continuous flow of updates that allow you to roll from one version of the Amazon Linux AMI to the next. For example, with the release of the 2012.09 Amazon Linux AMI, if you launch older versions of the Amazon Linux AMI (such as 2011.09 or 2012.03) and run yum update -y, you will still end up with the latest packages. You can disable rolling updates for the Amazon Linux AMI by enabling the lock-on-launch feature. The lock-on-launch feature locks your newly launched instance to receive updates only from the specified release of the AMI. For example, you can launch a 2012.03 AMI and have it receive only the updates that were released prior to the 2012.09 Amazon Linux AMI, until you are ready to migrate to the 2012.09 AMI. To enable lock-on-launch in new instances, launch a 2012.03 Amazon Linux AMI with the following user data passed to cloud-init, using either the EC2 console or the ec2-run-instances command with the -f flag.
#cloud-config repo_releasever:2012.03
Adding Packages
The Amazon Linux AMI is designed to be used with online package repositories hosted in each Amazon EC2 region. These repositories provide ongoing updates to packages in the Amazon Linux AMI, as well as access to hundreds of additional common open source server applications. The repositories are available in all regions and are accessed via yum update tools, as well as on the Linux AMI packages site. Hosting repositories in each region allows updates to be deployed quickly and without any data transfer charges.The packages can be installed by issuing yum commands, such as the following example:
# sudo yum install httpd
Access to the Extra Packages for Enterprise Linux (EPEL) repository is configured, but it is not enabled by default. EPEL provides third-party packages in addition to those that are in the Amazon Linux AMI repositories. The third-party packages are not supported by Amazon Web Services.
API Version 2013-02-01 77
Amazon Elastic Compute Cloud User Guide Accessing Source Packages for Reference
Important
EC2 instances launched into an Amazon Virtual Private Cloud (VPC) need to have an Internet Gateway attached to the VPC to contact the yum repository. For more information on Amazon VPC, go to the Amazon Virtual Private Cloud User Guide. If you find that the Amazon Linux AMI does not contain an application you need, you can simply install the application directly on your Amazon Linux AMI instance. The Amazon Linux AMI uses RPM and yum for package management, and that is likely the simplest way to install new applications. You should always check to see if an application is available in our central Amazon Linux AMI repository first, because many applications are available there. These applications can easily be added to your AMI instance. To upload your applications onto an Amazon Linux running instance, use scp or sftp and then configure the application by logging on to your instance.Your applications can also be uploaded during the instance launch by using the PACKAGE_SETUP action from built-in the cloud-init package. For more information, see cloud-init (p. 75).
The source RPM will be placed in the /usr/src/srpm/debug directory of your running Amazon EC2 instance. From there it can be unpacked, and, for reference, you can view the source tree using standard RPM tools. After you finish debugging, the package will be available for use in Amazon EC2.
Important
EC2 instances launched into an Amazon Virtual Private Cloud (Amazon VPC) need to have an Internet Gateway attached to the VPC to contact the yum repository. For information on Amazon VPC, go to the Amazon Virtual Private Cloud User Guide.
Developing Applications
A full set of Linux development tools is provided in the yum repository for the Amazon Linux AMI. To develop applications on the Amazon Linux AMI, simply select the development tools you need with yum. Alternatively, many applications developed on CentOS and other similar distributions should run on the Amazon Linux AMI.
Important
EC2 instances launched into an Amazon Virtual Private Cloud (Amazon VPC) need to have an Internet Gateway attached to the VPC to contact the yum repository. For information on adding an Internet Gateway to your Amazon VPC, go to the Amazon Virtual Private Cloud User Guide.
Security Updates
Security updates are provided via the Amazon Linux AMI yum repositories as well as via updated Amazon Linux AMIs. Security alerts will be published in the Amazon Linux AMI Security Center. For more information on AWS security policies or to report a security problem, visit the AWS Security Center. Amazon Linux AMIs are configured to download and install security updates at launch time. This is controlled via a cloud-init setting called repo_upgrade. The following snippet of cloud-init configuration shows how you can change the settings in the user data text you pass to your instance initialization:
#cloud-config repo_upgrade:security
The possible values for the repo_upgrade setting are as follows: security Apply outstanding updates that Amazon marks as security updates. bugfix Apply updates that Amazon marks as bug fixes. Bug fixes are a larger set of updates, which include security updates and fixes for various other minor bugs. all Apply all applicable available updates, regardless of their classification. none Do not apply any updates to the instance on startup.
The default setting for repo_upgrade is security. That is, if you don't specify a different value in your user data, by default the Amazon Linux AMI will perform the security upgrades at launch for any packages
installed at that time. Amazon Linux AMI will also notify you of any updates to the installed packages by listing the number of available updates upon login using the motd. To install these updates, you will need to run sudo yum upgrade on the instance.
Important
EC2 instances launched into an Amazon Virtual Private Cloud (Amazon VPC) need to have an Internet Gateway attached to the VPC to contact the yum repository. For information on adding an Internet Gateway to Amazon VPC, go to the Amazon Virtual Private Cloud User Guide.
Support
Support for installation and use of the base Amazon Linux AMI is included through subscriptions to AWS Premium Support. For more information, go to Premium Support. Youre encouraged to post any questions you have on using the Amazon Linux AMI to the Amazon EC2 forums. You can report bugs either to Premium Support or the Amazon EC2 forums.
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
initrd
3. Populate
boot/grub/menu.lst
referencing your kernel. 4. Select an appropriate AKI ID from the Amazon Kernel Image IDs section that follows. 5. Bundle the AMI and set the default to your chosen AKI. 6. Upload and register your new AMI. 7. For existing AMIs, you can simply specify the appropriate AKI ID when you call RunInstances or when you use the AWS Management Console. Note: To update an existing AMI to use a user-provided kernel, re-launch the AMI and follow steps 1 through 6 specified in the preceding task list. For procedures associated with the preceding task list, see Using the User-Provided Kernel (p. 84).
Important
You must modify your own menu.lst for your specific environment.
default 0 timeout 3 fallback 1 title Vanilla EC2 Kernel 2.6.32.10 root (hd0) kernel /boot/vmlinux-2.6.32.10-ACME_SYS_EC2 root=/dev/sda1 initrd /boot/initrd-2.6.32.10-ACME_SYS_EC2 title Ubuntu EC2 2.6.32.302-EC root (hd0) kernel /boot/ubuntu-ec2 root=/dev/sda1 initrd /boot/initrd-ec2
We recommend that you use option two to control the kernel booting for two reasons. First, Amazon EC2 users dont have interactive control over the boot process because there is no keyboard access. GRUB will proceed without user interaction. Second, and most important for Amazon EC2 instances, you want to protect against distributions that auto-update the default kernel and break your image. By not relying on the auto-update mechanism and explicitly choosing which kernel you run, you reduce the risk of an incompatible kernel becoming the default kernel.
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
A fallback kernel does not have to be specified in your menu.lst, but we recommend that you have a fallback when you test new kernels. GRUB can fall back to another kernel in the event that the new kernel fails. Having a fallback kernel allows the instance to boot even if the new kernel is not found.
Note
You cannot use the 64-bit version of PV-GRUB to start a 32-bit kernel or vice versa.
Note
You must not specify an Amazon ramdisk image (ARI) when using a PV-GRUB AKI. The following AKI IDs should be used by users who are either registering new AMIs or who want to launch existing AMIs using PV-GRUB. Each AKI type is available in all Amazon EC2 Regions: US-East-1 aki-88aa75e1 pv-grub-hd0_1.03-x86_64.gz aki-b6aa75df pv-grub-hd0_1.03-i386.gz aki-b4aa75dd pv-grub-hd00_1.03-x86_64.gz aki-b2aa75db pv-grub-hd00_1.03-i386.gz US-West-1 aki-f77e26b2 pv-grub-hd0_1.03-x86_64.gz aki-f57e26b0 pv-grub-hd0_1.03-i386.gz aki-eb7e26ae pv-grub-hd00_1.03-x86_64.gz aki-e97e26ac pv-grub-hd00_1.03-i386.gz US-West-2 aki-fc37bacc pv-grub-hd0_1.03-x86_64.gz aki-fa37baca pv-grub-hd0_1.03-i386.gz aki-f837bac8 pv-grub-hd00_1.03-x86_64.gz aki-f637bac6 pv-grub-hd00_1.03-i386.gz EU-West-1 aki-71665e05 pv-grub-hd0_1.03-x86_64.gz aki-75665e01 pv-grub-hd0_1.03-i386.gz aki-8b655dff pv-grub-hd00_1.03-x86_64.gz aki-89655dfd pv-grub-hd00_1.03-i386.gz
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
AP-SouthEast-1 aki-fe1354ac pv-grub-hd0_1.03-x86_64.gz aki-f81354aa pv-grub-hd0_1.03-i386.gz aki-fa1354a8 pv-grub-hd00_1.03-x86_64.gz aki-f41354a6 pv-grub-hd00_1.03-i386.gz AP-SouthEast-2 aki-3f990e05 pv-grub-hd00_1.03-i386.gz aki-3d990e07 pv-grub-hd00_1.03-x86_64.gz aki-33990e09 pv-grub-hd0_1.03-i386.gz aki-31990e0b pv-grub-hd0_1.03-x86_64.gz AP-NorthEast-1 aki-44992845 pv-grub-hd0_1.03-x86_64.gz aki-42992843 pv-grub-hd0_1.03-i386.gz aki-40992841 pv-grub-hd00_1.03-x86_64.gz aki-3e99283f pv-grub-hd00_1.03-i386.gz SA-East-1 aki-c48f51d9 pv-grub-hd0_1.03-x86_64.gz aki-ca8f51d7 pv-grub-hd0_1.03-i386.gz aki-c88f51d5 pv-grub-hd00_1.03-x86_64.gz aki-ce8f51d3 pv-grub-hd00_1.03-i386.gz US-Gov-West-1 aki-79a4c05a pv-grub-hd0_1.03-x86_64.gz aki-7ba4c058 pv-grub-hd0_1.03-i386.gz aki-75a4c056 pv-grub-hd00_1.03-x86_64.gz aki-77a4c054 pv-grub-hd00_1.03-i386.gz
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
It is possible that your specific Linux kernel will not boot using the new PV-GRUB method. If that occurs, select a different kernel or use a non-PV-GRUB AKI to boot your instance.
Note
These are the /boot file systems that we have tested and verified. Others could boot from PV-GRUB, but havent been tested.
Important
The specific details of configuring your AMI to use PV-GRUB will vary depending on your exact Linux environment. The following example is for openSUSE 11.2.
# rpm ivh /tmp/kernel-ec2-2.6.35-rc4.8.1.x86_64.rpm warning: /tmp/kernel-ec2-2.6.35-rc4.8.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID a29f6635 Preparing... ########################################### [100%] 1:kernel-ec2 Kernel image: Initrd image: Root device: Features: 14807 blocks ########################################### [100%] /boot/vmlinux-2.6.35-rc4-8-ec2 /boot/initrd-2.6.35-rc4-8-ec2 /dev/sda1 (mounted on / as ext3) block
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
block
Important
Your must modify your own menu.lst for your specific environment.
default 0 timeout 3 title EC2 root (hd0) kernel /boot/vmlinux-ec2 root=/dev/sda1 initrd /boot/initrd-ec2
4. Select an appropriate AKI ID from the Amazon Kernel Image IDs section that follows. For this host, weve chosen aki-88aa75e1 because we are bundling an AMI. Do not specify an Amazon ramdisk image (ARI) when using a PV-GRUB AKI. 5. For new AMIs or Amazon EBS volumes, bundle the AMI and set the default to your chosen AKI from your running Linux instance.
# ec2-bundle-vol -r x86_64 -d /mnt -p openSUSE-11.2-PV-GRUB -u [AWS-ID] -k /mnt/pkey.pem -c /mnt/cert.pem -s 10240 -e /mnt,/root/.ssh --kernel aki88aa75e1
6. Upload the bundle from your running Linux instance to Amazon S3.
# ec2-upload-bundle -b MyReallyCoolBucketLocation -m /mnt/openSUSE-11.2-PV GRUB.manifest.xml -a MyAccessKey -s MySecretKey
7. Register the AMI with the AKI (aki-88aa75e1) from your desktop using the Amazon EC2 command line tools.
$ ec2-register -name openSUSE-11.2-PVGRUB MyReallyCoolBucketLocation/openSUSE11.2-PVGRUB.manifest.xml
Note
The AP-SouthEast-2 region only provides support for PV-GRUB to load a kernel of your choice from the AMI.
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
Kernel FAQ
Q: What are user selectable kernels? Amazon EC2 provides user selectable kernels which enables you to select a kernel when bundling an AMI or launching an instance. User selectable kernels are useful for keeping your instances up to date with security fixes and updates, being able to use functionality provided by new distributions, and for using specialty applications that have unique timing requirements. Q: How do I find user selectable kernels?
Amazon Elastic Compute Cloud User Guide Enabling Your Own Linux Kernels
Use ec2-describe-images -o amazon --filter "image-type=kernel". This lists all public kernels that are currently available. Q: What type of dependencies do kernels have? Kernels are most likely to require a RAM disk that contains required drivers (for example, Xen drivers, video drivers, and so on). If you launch a kernel without a required RAM disk, it will not work properly. Q: How do I know a kernel/AMI combination will work together? If you are concerned about whether the kernel/image combination will work well together, Amazon provides several AMIs that have tested combinations that you can use as a starting point for your AMIs or AMIs that you can use as a foundation for a public AMIs. If you require a certified kernel/ AMI combination, you can find them as paid AMIs through organizations such as RedHat. For more information, see Paid AMIs (p. 30). Q: Can I use my own kernel? Yes. For more information, see Enabling Your Own Linux Kernels (p. 80). Q: How do I know which kernels are compatible with PV-GRUB? For a list of compatible PV-GRUB kernels, see Distribution Kernels Compatible with EC2 (p. 83). Some Linux distributions provide kernels that are not compatible with Amazon EC2. We are working with vendors to ensure that the most popular AMIs provide kernels that work with Amazon EC2, and we have tested a number of these AMIs and found them to be compatible with PV-GRUB. Unfortunately, it is not possible to support every kernel that is or can be compiled. To avoid the situation in which a kernel does not work consistently or at all, we recommend that you use a known good kernel, select a non-PV-GRUB AKI, or seek support from your AMI vendor. Q: In what runlevel do instances start? If you use one of the Xen provided kernels to boot your EC2 instance it will default to run level 4. However if you use PV-GRUB to boot your own kernel inside of the instance, the instance will then default to the internally configured run level. Q: Which PV-GRUB kernel should I use? It is recommended that you always use the latest version of the PV-GRUB AKI, as not all versions of the PV-GRUB AKI will be compatible with all instance types. Use the following command to get a list of the PV-GRUB AKIs:
$ ec2-describe-images -o amazon --filter "manifest-location=*pv-grub-hd0*"
Your instance keeps running until you stop or terminate it, or until it fails. If an instance fails, you can launch a new one from the AMI. Your AWS account has a limit on the number of instances that you can have running. For more information about these limits, and how to request an increase in your limits, see How many instances can I run in Amazon EC2 in the Amazon EC2 General FAQ.
Related Topics
Amazon Machine Images (AMI) (p. 22) Amazon EC2 Instance Store (p. 536)
Instance Basics
Topics Instance Families and Types (p. 89) Regions and Availability Zones (p. 119) Supported Platforms (p. 124) Root Device Volume (p. 127) Instance Best Practices (p. 133) This section provides information about key concepts to help you understand Amazon EC2 instances.
High Storage Instances (p. 104) Cluster Instances (p. 106) Amazon Elastic Compute Cloud (Amazon EC2) instances are grouped into the general families described in the following table. Family Cluster Compute Description Have a very large amount of CPU coupled with increased networking performance. They're well-suited for High Performance Compute (HPC) applications and other demanding network-bound applications. For more information, see Overview (p. 106). Provide general-purpose graphics processing units (GPUs), with proportionally high CPU and increased network performance for applications that benefit from highly parallelized processing. They're well-suited for HPC applications as well as rendering and media processing applications. For more information, see Overview (p. 106). Have proportionally more CPU resources than memory (RAM). They're well-suited for compute-intensive applications. Provide tens of thousands of low-latency, random I/O operations per second (IOPS) to an application. They're well-suited for NoSQL databases, clustered databases, and OLTP (online transaction processing) systems. For more information, see High I/O Instances (p. 103). Have proportionally more memory resources.They're well suited for high-throughput applications, such as database and memory caching applications. Have large amounts of memory coupled with high CPU and network performance. These instances are well suited for in-memory analytics, graph analysis, and scientific computing applications. Provide very high storage density and high sequential read and write performance per instance. They are well-suited for data warehousing, Hadoop/MapReduce, and parallel file systems. For more information, see High Storage Instances (p. 104). Provide a small amount of consistent CPU resources and enable you to burst CPU capacity when additional cycles are available. They're well-suited for lower throughput applications and websites that consume significant compute cycles periodically. For more information, see Micro Instances (p. 96). Have memory-to-CPU ratios suitable for most general-purpose applications.
Cluster GPU
Micro
Standard
Tip
One of the advantages of Amazon EC2 is that you pay by the instance hour, which makes it convenient and inexpensive to test the performance of your application on different instance families and types. A good way to determine the most appropriate instance family and instance type is to launch test instances and benchmark your application.
Name
Memory
Instance Architecture I/O Available API Name Store P ormance for Spot erf Volumes* Instance
Cluster Compute Cluster 60.5 GiB Compute Eight Extra Large 88 16 (2 x 3360 GiB 64-bit Intel (4 x 840 Xeon GiB) E5-2670, eight-core with hyperthread) 8 (2 x 1690 GiB 64-bit Intel (2 x 840 Xeon GiB) X5570, quad-core with hyperthread) Very high Yes (10 Gbps Ethernet)
cc2.8xlarge
33.5
cc1.4xlarge
Cluster GPU Cluster GPU Quadruple Extra Large** 22.5 GiB 33.5 (see note after this table) 8 (2 x 1680 GiB 64-bit Intel (2 x 840 Xeon GiB) X5570, quad-core with hyperthread), plus 2 NVIDIA Tesla M2050 GPUs Very high Yes (10 Gbps Ethernet)
cg1.4xlarge
High CPU High-CPU 7 GiB Extra Large High-CPU 1.7 GiB Medium High I/O High I/O 60.5 GiB Quadruple Extra Large*** High Memory High-Memory 34.2 GiB Double Extra Large 13 4 (with 3.25 ECUs each) 840 GiB (1 x 840 GiB) 64-bit High Yes
m2.2xlarge
20
8 (with 1680 GiB 64-bit 2.5 ECUs (4 x 420 each) GiB) 2 (with 340 GiB 2.5 ECUs (1 x 340 each) GiB) 32-bit and 64-bit
High
Yes
c1.xlarge
Moderate Yes
c1.medium
35
hi1.4xlarge
Name
Memory
Compute Virtual Units Cores 6.5 2 (with 3.25 ECUs each) 8 (with 3.25 ECUs each)
Instance Architecture I/O Available API Name Store P ormance for Spot erf Volumes* Instance 410 GiB (1 x 410 GiB) 64-bit Moderate Yes
m2.xlarge
High-Memory 17.1 GiB Extra Large High-Memory 68.4 GiB Quadruple Extra Large
26
High
Yes
m2.4xlarge
High-Memory Cluster High-Memory 244 GiB Cluster Eight Extra Large High Storage High Storage Eight Extra Large Micro Micro 615 MiB Up to 2 (for short periodic bursts) 1 None (use Amazon EBS volumes for storage) 32-bit and 64-bit Low Yes
t1.micro
88
64-bit
cr1.8xlarge
117 GiB
35
64-bit
hs1.8xlarge
Standard M1 Extra Large 15 GiB 8 4 (with 2 ECUs each) 2 (with 2 ECUs each) 1 1680 GB (4 x 420 GiB) 840 GiB (2 x 420 GiB) 400 GiB (1 x 400 GiB) 150 GiB (1 x 150 GiB) 64-bit High Yes
m1.xlarge
64-bit
Moderate Yes
m1.large
M1 Medium
3.75 GiB
Moderate Yes
m1.medium
Moderate Yes
m1.small
Name
Memory
Compute Virtual Units Cores 26 8 (with 3.25 ECUs each) 4 (with 3.25 ECUs each)
Instance Architecture I/O Available API Name Store P ormance for Spot erf Volumes* Instance EBS storage only EBS storage only 64-bit High Yes
m3.2xlarge
30 GiB
15 GiB
13
64-bit
Moderate Yes
m3.xlarge
* Instance store volumes may not be mounted by default. For more information, see Instance Store Device Names (p. 538). ** The hi1.4xlarge instance type is based on solid-state drive (SSD) technology. For more information, see High I/O Instances (p. 103). ***The cg1.4xlarge instance type has 1 GiB reserved for GPU operation. The 21.5 GiB doesn't include the on-board memory of the GPUs, which is 3 GiB per GPU for the NVIDIA Tesla M2050.
EBS-Optimized Instances
An EBS-Optimized instance uses an optimized configuration stack and provides additional, dedicated capacity for EBS I/O. This optimization provides the best performance for your EBS volumes by minimizing contention between EBS I/O and other traffic from your Amazon EC2 instance. EBS optimization enables instances to fully utilize the IOPS provisioned on an EBS volume. EBS-Optimized instances deliver dedicated throughput to EBS, with options between 500 Mbps and 1,000 Mbps, depending on the instance type you use. When attached to an EBS-Optimized instance, Provisioned IOPS volumes are designed to deliver within 10 percent of their provisioned performance 99.9 percent of the time in a given year. For more information, see Provisioned IOPS Volumes (p. 486). The following instance types can be launched as EBS-Optimized instances: M1 Large (m1.large) M1 Extra Large (m1.xlarge) High-Memory Quadruple Extra Large (m2.4xlarge) When you use an EBS-Optimized instance, you pay an additional low, hourly fee for the dedicated capacity.
cc2.8xlarge
Type
Name
Cluster GPU Quadruple Extra Large High-CPU Extra Large High-CPU Medium High I/O Quadruple Extra Large High-Memory Double Extra Large High-Memory Extra Large High-Memory Quadruple Extra Large
High-Memory Cluster Eight Extra Large cr1.8xlarge High Storage Eight Extra Large M1 Extra Large M1 Large M1 Medium M1 Small M3 Double Extra Large M3 Extra Large Micro
hs1.8xlarge m1.xlarge m1.large m1.medium m1.small m3.2xlarge m3.xlarge t1.micro
Microsoft Windows Server 2008 (64-bit) Microsoft Windows Server 2008 R2 (64-bit) Microsoft Windows Server 2012 (64-bit)
The Windows public AMIs that Amazon provides are unmodified versions of Windows with the following two exceptions: we added drivers to improve the networking and disk I/O performance and we created the Amazon EC2 configuration service. The Amazon EC2 configuration service performs the following functions: Randomly sets the Administrator password on initial launch, encrypts the password with the users SSH key, and reports it to the console. This operation happens upon initial AMI launch. If you change the password, AMIs that are created from this instance use the new password. Configures the computer name to the internal DNS name. For more information about how to determine the internal DNS name, see Amazon EC2 Instance IP Addressing (p. 457). Sends the last three system and application errors from the event log to the console. This helps developers to identify problems that caused an instance to crash or network connectivity to be lost. For more information about the EC2 configuration service, see Using Ec2Config Service in the Microsoft Windows Guide.
Note
We use several internal benchmarks and tests to manage the consistency and predictability of the performance of an Amazon EC2 Compute Unit. For more information, see the Instance page. To find out which instance works best for your application, we recommend launching an instance and using your own benchmark application. This helps you determine which instance type works best for your specific use case.
I/O Resources
Amazon EC2 provides virtualized server instances. Whereas some resources like CPU, memory, and instance storage are dedicated to a particular instance, other resources such as the network and the disk subsystem are shared among instances. If each instance on a physical host tries to use as much of one of these shared resources as possible, each receives an equal share of that resource. However, when a resource is under-utilized, you are often able to consume a higher share of that resource while it is available. The different instance types provide higher or lower minimum performance from the shared resources depending on their size. Each of the instance types has an I/O performance indicator (low, moderate, high, etc.). Instance types with high I/O performance have a larger allocation of shared resources. Allocating a larger share of shared resources also reduces the variance of I/O performance. For most applications,
moderate I/O performance is more than enough. However, for applications that require greater or more consistent I/O performance, consider instances with higher I/O performance.
Instance Tags
To help categorize and manage your instances, you can assign tags of your choice to them. For more information, see Tagging Your Amazon EC2 Resources (p. 566).
Micro Instances
Topics Optimal Application of Micro Instances (p. 96) Available CPU Resources During Spikes (p. 98) When the Instance Uses Its Allotted Resources (p. 98) Comparison with the m1.small Instance Type (p. 100) AMI Optimization for Micro Instances (p. 102) Related Topics (p. 103) Micro instances (t1.micro) provide a small amount of consistent CPU resources and allow you to increase CPU capacity in short bursts when additional cycles are available. They are well suited for lower throughput applications and web sites that require additional compute cycles periodically. This section describes how micro instances generally work so you can understand how to apply them. Our intent is not to specify exact behavior, but to give you visibility into the instance's behavior so you can understand its performance (to a greater degree than you typically get with, for example, a multi-tenant shared web hosting system). The micro instance is available on both 32-bit and 64-bit platforms, but it's available as an Amazon EBS-backed instance only. For basic specifications for the micro instance type, see Available Instance Types (p. 90).
The instance is designed to operate with its CPU usage at essentially only two levels: the normal low background level, and then at brief spiked levels much higher than the background level. We allow the instance to operate at up to 2 EC2 compute units (ECUs) (for more information, see Compute Resources Measurement (p. 95)). The ratio between the maximum level and the background level is designed to be large. Micro instances are designed to support tens of requests per minute on your application. However, actual performance can vary significantly depending on the amount of CPU resources required for each request on your application. Your application might have a different CPU usage profile than that described in the preceding section. The next figure shows the profile for an application that isn't appropriate for a micro instance. The application requires continuous data-crunching CPU resources for each request, resulting in plateaus of CPU usage that the micro instance isn't designed to handle.
The next figure shows another profile that isn't appropriate for a micro instance. Here the spikes in CPU use are brief, but they occur too frequently to be serviced by a micro instance.
The next figure shows another profile that isn't appropriate for a micro instance. Here the spikes aren't too frequent, but the background level between spikes is too high to be serviced by a micro instance.
In each of the preceding cases of workloads not appropriate for a micro instance, we recommend you consider using a different instance type (for more information about the instance types, see Instance Families and Types (p. 89)).
instance so it operates at a low CPU level. If your instance continues to use all of its allotted resources, its performance will degrade. We will increase the time we limit its CPU level, thus increasing the time before the instance is allowed to burst again. If you enable Amazon CloudWatch monitoring for your micro instance, you can use the "Avg CPU Utilization" graph in the AWS Management Console to determine whether your instance is regularly using all its allotted CPU resources. We recommend that you look at the maximum value reached during each given period. If the maximum value is 100%, we recommend that you use Auto Scaling to scale out (with additional micro instances and a load balancer), or move to a larger instance type. For more information about Auto Scaling, go to the Auto Scaling Developer Guide.
Note
Micro instances are available as either 32-bit or 64-bit. If you need to move to a larger instance, make sure to move to a compatible instance type. The following figures show the three suboptimal profiles from the preceding section and what it might look like when the instance consumes its allotted resources and we have to limit its CPU level. If the instance consumes its allotted resources, we restrict it to the low background level. The next figure shows the situation with the long plateaus of data-crunching CPU usage. The CPU hits the maximum allowed level and stays there until the instance's allotted resources are consumed for the period. At that point, we limit the instance to operate at the low background level, and it operates there until we allow it to burst above that level again. The instance again stays there until the allotted resources are consumed and we limit it again (not seen on the graph).
The next figure shows the situation where the requests are too frequent. The instance uses its allotted resources after only a few requests and so we limit it. After we lift the restriction, the instance maxes out its CPU usage trying to keep up with the requests, and we limit it again.
The next figure shows the situation where the background level is too high. Notice that the instance doesn't have to be operating at the maximum CPU level for us to limit it. We limit the instance when it's operating above the normal background level and has consumed its allotted resources for the given period. In this case (as in the preceding one), the instance can't keep up with the work, and we limit it again.
The following figures compare the CPU usage of a micro instance with an m1.small for the various scenarios we've discussed in the preceding sections. The first figure that follows shows an optimal scenario for a micro instance (the left graph) and how it might look for an m1.small (the right graph). In this case, we don't need to limit the micro instance. The processing time on the m1.small would be longer for each spike in CPU demand compared to the micro instance.
The next figure shows the scenario with the data-crunching requests that used up the allotted resources on the micro instance, and how they might look with the m1.small instance.
The next figure shows the frequent requests that used up the allotted resources on the micro instance, and how they might look on the m1.small instance.
The next figure shows the situation where the background level used up the allotted resources on the micro instance, and how it might look on the m1.small instance.
can be memory intensive and require long-running CPU resources. We recommend you first use a larger instance type when performing these changes to the AMI, and then run the AMI on a micro instance for normal operations.
Related Topics
Instance Families and Types (p. 89)
Hardware Specifications
The hi1.4xlarge instance type is based on solid-state drive (SSD) technology. The hardware specifications for hi1.4xlarge instances are described in the following table. Item Processor Virtual cores Memory Platform Network Instance store volumes Description 35 EC2 compute units 16 virtual cores (8 cores + 8 hyperthreads) 60.5 GiB 64-bit 10 Gbps Ethernet 2 x 1 TiB (SSD)
SSD Storage
This section contains important information you need to know about SSD storage. With SSD storage: The primary data source is an instance store with SSD storage. Read performance is consistent and write performance can vary. Write amplification can occur. The TRIM command is not currently supported.
Write Amplification
Write amplification refers to an undesirable condition associated with flash memory and SSDs, where the actual amount of physical information written is a multiple of the logical amount intended to be written. Because flash memory must be erased before it can be rewritten, the process to perform these operations results in moving (or rewriting) user data and metadata more than once. This multiplying effect increases the number of writes required over the life of the SSD, which shortens the time that it can reliably operate. High I/O instances are designed with a provisioning model intended to minimize write amplification. Random writes have a much more severe impact on write amplification than serial writes. If you are concerned about write amplification, allocate less than the full tebibyte of storage for your application (also known as over provisioning).
Related Topics
Instance Families and Types (p. 89)
Data warehousing Hadoop/MapReduce Parallel file systems By default, you can run up to two high storage instances. If you need more than two high storage instances, you can request more using the Amazon EC2 Instance Request Form. You can cluster high storage instances in a cluster placement group. The placement group cannot contain other cluster instances.
Hardware Specifications
High storage instances support both EBS-backed and instance-store-backed Amazon Machine Images (AMIs). High storage instances support both paravirtual (PV) and hardware virtual machine (HVM) AMIs. High storage instances are capable of delivering 2.4 GB per second of sequential read and 2.6 GB per second of sequential write performance when using a block size of 2 MiB. For customers using Microsoft Windows Server, high storage instances are only supported with the Microsoft Windows Server AMIs for Cluster Instance Type. Cluster compute, cluster GPU, high I/O, and high storage instances do not currently support EBS optimization, but provide high bandwidth networking and can also be used with Amazon Elastic Block Store (EBS) provisioned I/O operations per second (IOPS) volumes for improved consistency and performance. For customers using Linux, Linux kernel version 3.3 and higher contain a bug that can cause instability, crashes, and possible data corruption under high I/O load. A fix for this bug has been submitted to the Linux kernel. We recommend using AMIs based on Linux kernel version 3.3 or lower for hs1.8xlarge instances until the issue has been addressed in the stable kernel releases. The hardware specifications for the hs1.8xlarge instance type are described in the following table. Item Processor Virtual cores Memory Platform Network Instance store volumes Description 35 EC2 compute units 16 virtual cores (8 cores + 8 hyperthreads) 117 GiB 64-bit 10 Gbps Ethernet 2 x 24 TB hard disk drives
Storage Information
This section contains important information you need to know about the storage used with high storage instances.
Disk Initialization
If you plan to run your hs1.8xlarge instance in a steady state for long periods of time, we recommend that you zero the hard disks first for improved performance. This process can take as long as six hours to complete.
Related Topics
Instance Families and Types (p. 89)
Cluster Instances
Topics Overview (p. 106) How to Launch Cluster Instances in a Placement Group (p. 108) How to Delete a Placement Group (p. 113) AWS CloudFormation Templates for Cluster Instances (p. 115) Using the NVIDIA Driver on a Cluster GPU Instance (p. 116) Cluster Instance Hardware Specifications (p. 117) In this topic, you'll learn about cluster instances and how to create hardware virtual machine (HVM) AMIs. You'll also learn how to create placement groups and then launch cluster instances into them.
Overview
Amazon Elastic Compute Cloud (Amazon EC2) offers two cluster instance types: cluster compute instances and cluster graphics processing unit (GPU) instances. These instance types provide a very large amount of computational power coupled with increased network performance. They are well suited for High Performance Computing (HPC) applications and other demanding network-bound applications, such as science and engineering applications, financial modeling applications, and business analytics applications. Cluster GPU instances have the same networking and placement group properties as cluster compute instances, but also include NVIDIA Tesla M2050 GPUs. These GPUs can be used to accelerate many scientific, engineering, and rendering applications by leveraging the Compute Unified Device Architecture (CUDA) or OpenCL parallel computing frameworks.
You can logically group cluster instances into clusters, known as cluster placement groups. This enables applications to get the full-bisection bandwidth and low-latency network performance required for tightly coupled, node-to-node communication typical of many HPC applications. A cluster placement group is a logical grouping of cluster instances within a single Availability Zone. A placement group cannot span multiple Availability Zones. You first create a placement group and then launch multiple cluster instances into the placement group. You must give each placement group a name that is unique within your AWS account.
Important
We recommend that you launch the minimum number of instances that you need in the placement group in a single launch request. If you launch only a few instances and try to add more instances to the placement group later, you increase your chances of getting an "Insufficient Capacity" error. If you do receive an "Insufficient Capacity" error, stop and restart the instances in the placement group, and try to add more instances again.
Tip
You can't merge cluster placement groups. Instead, you must terminate the instances in one group, and then relaunch those instances into the other group. A cluster instance is an Amazon EC2 instance type. This means that cluster instances interoperate with other Amazon EC2 features and AWS cloud services just as other Amazon EC2 instance types do. The functionality of cluster instances is similar to the functionality of other Amazon EC2 instance types, but with the important differences described in the following table and sections. Feature Description
Cluster Placement Groups Provides low latency and high-bandwidth connectivity between the cluster instances within a single Availability Zone. You just create a placement group and then launch cluster instances into it. Instances launched within a placement group participate in a full-bisection bandwidth cluster appropriate for HPC applications. HVM-Based Virtualization Cluster instances run as hardware virtual machine (HVM)-based instances. HVM virtualization uses hardware-assist technology provided by the AWS platform. With HVM virtualization, the guest VM runs as if it were on a native hardware platform, except that it still uses paravirtual (PV) network and storage drivers for improved performance. For more information, see HVM-Based AMIs (p. 108). Amazon EBS-Backed, HVM-Based AMIs You must launch cluster instances from Amazon EBS-backed, HVM-based AMIs. Launching an instance from an Amazon EC2 instance store-backed AMI is not supported. AWS labels all AMIs as either hvm or paravirtual so you can determine the virtualization type. For information about using Amazon EBS-backed AMIs, see Storage for the Root Device (p. 23).
Current Limitations
Cluster instances currently have the following limitations: Cluster instance types aren't available in every Region. For more information, see the Amazon EC2 Release Notes. Cluster instance types aren't available for use with Amazon DevPay. Cluster placement groups currently have the following limitations: Amazon EC2 Reserved Instances are not guaranteed within a specific requested placement group. A cluster placement group can't span multiple Availability Zones.
API Version 2013-02-01 107
A cluster placement group can't contain cluster instances of different instance types.
HVM-Based AMIs
Cluster instances require the use of HVM-based, Amazon EBS-backed AMIs. Paravirtual (PV) AMIs employed by Linux instances and other EC2 instance types that use paravirtual machine (PVM)-based virtualization are not supported. Cluster instances do not require the use of Amazon Kernel Images (AKIs) or Amazon RAM disk Images (ARIs) that are part of PVM-based AMIs used with other EC2 instance types.
Reference AMIs
To help you get started with cluster instances, AWS provides a reference Amazon Linux AMI and a reference Amazon Windows AMI. These reference AMIs include the NVIDIA driver and CUDA toolkit, which enable the NVIDIA GPUs. This topic shows you how to customize a cluster instance and create your own AMI from it. To learn more about the Amazon Linux reference AMI, go to Amazon Linux AMI. To learn more about the Amazon Windows AMIs, go to Amazon Machine Images (AMIs).
The next sections show you how to complete these steps using the AWS Management Console, the command line tools, or the API.
3.
2.
2. 3.
2.
For example:
PROMPT> ec2-create-image -n "My_Custom_HVM_AMI" i-1a2b3c4d
Amazon EC2 begins creating the image and returns the new image's ID. For example:
IMAGE ami-5f4d3a2b
2.
2. 3.
Record the name of the placement group. You'll need this name when you launch your cluster instances into this group. Use the ec2-describe-placement-groups command to get details about your cluster placement groups. If you do not specify the name of the cluster placement group, details about all the placement groups in your account are returned.
PROMPT> ec2-describe-placement-groups
hvm
2.
2.
To get information about your cluster placement groups, construct a Query request similar to the following.
Action=DescribePlacementGroups &GroupName.1=XYZ-cluster &AUTHPARAMS...
To terminate an instance
1. 2. 3. 4. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. In the Navigation pane, click Instances. Right-click the instance, and then click Terminate. When prompted for confirmation, click Yes, Terminate.
After you've terminated the cluster instances in a placement group, use the following steps to delete the placement group.
2. 3.
To terminate an instance
Use the ec2-terminate-instances command. This example command terminates the instance with the instance ID i-10a64379.
ec2-terminate instances i-10a64379
After you've terminated the cluster instances in a placement group, use the following steps to delete the placement group.
API
Before you delete your placement group, first you need to terminate all running instances in the group.
To terminate an instance
Construct a Query request similar to the following example.
https://ec2.amazonaws.com/?Action=TerminateInstances &InstanceId.1=i-10a64379 &AUTHPARAMS
After you've terminated the cluster instances in a placement group, use the following steps to delete the placement group.
For more information about using AWS CloudFormation, see the AWS CloudFormation User Guide.
Important
The Amazon-provided CUDA toolkit package has dependencies on the NVIDIA drivers. Uninstalling the NVIDIA packages erases the CUDA toolkit. You will need to reinstall the CUDA toolkit after installing the NVIDIA driver.
Tip
You can download NVIDIA drivers at http://www.nvidia.com/Download/Find.aspx. Look for the Tesla M-Class M2050 driver for Linux 64-bit systems.
2.
3. 4.
5.
The response lists the installed NVIDIA driver version and details about the GPUs. Confirm that the GPUs are exposed.
[root@ip-xxx ~]# ls /dev/*nv* /dev/nvidia0 /dev/nvidia1 /dev/nvidiactl /dev/nvram
If a newer version of the NVIDIA driver is available, you might want to update your instance to use it. To update your instance, follow the steps in the preceding section for installing the driver, and run the self-install script from the newly downloaded driver version. To install the CUDA toolkit package, download the package from the NVIDIA website, and run the self-install script as outlined in step 2 of the preceding section for installing the driver.
Processor
23 GiB 244 GiB Note: The cluster GPU instances can use up to 22 GiB, with 1 GiB reserved for GPU operation. The 22 GiB doesn't include the GPU on-board memory, which is 3 GiB per GPU for the NVIDIA Tesla M2050 GPU. 64-bit 10 Gbps Ethernet 1680 GiB instance 64-bit storage (2 x 840 GiB) 64-bit 10 Gbps Ethernet
240 GiB instance 64-bit 3360 GiB instance 64-bit storage (2 x 120 GiB SSD) storage (4 x 840 GiB) N/A
GPUs (cluster Two NVIDIA Tesla M2050 N/A GPU instances GPUs only) Note: The instance must have the corresponding NVIDIA driver installed; the reference AMI we provide includes the driver. If you need to download and install the driver, see Manual Installation of the NVIDIA Driver (p. 116).
When determining the number of cluster instances you can launch, be aware that you're limited to a maximum of 20 EC2 instances, of which two can be cluster GPU instances. If you need more instances, use the Request to Increase Amazon EC2 Instance Limit form. For more information, see Instance Families and Types (p. 89).
Amazon Elastic Compute Cloud User Guide Regions and Availability Zones
Regions
Amazon EC2 provides multiple regions so you can launch Amazon EC2 instances in locations that meet your requirements. For example, you might want to launch instances in Europe to be closer to your European customers or to meet legal requirements. Each Amazon EC2 region is designed to be completely isolated from the other Amazon EC2 regions. This achieves the greatest possible failure independence and stability, and it makes the locality of each EC2 resource unambiguous. When launch or work with instances, you must specify the correct regional endpoint. For example, to access the US East (Northern Virginia) Region , make service calls using the ec2.us-east-1.amazonaws.com service endpoint.
Amazon Elastic Compute Cloud User Guide Regions and Availability Zones
Note
Data transfer between regions is charged at the Internet data transfer rate for both the sending and the receiving region. For detailed information about Amazon EC2 charges, go to the Amazon EC2 Product Page. For information about the regions and endpoints for Amazon EC2, go to Regions and Endpoints in the Amazon Web Services General Reference.
Availability Zones
Amazon operates state-of-the-art, highly available data center facilities. However, failures can occur that affect the availability of instances that are in the same location. Although this is rare, if you host all your Amazon EC2 instances in a single location that is affected by such a failure, none of your instances would be available. For example, if you have instances distributed across three Availability Zones and one of the instances fails, you can design your application so the instances in the remaining Availability Zones handle any requests. Availability Zones are mapped independently for each account.Therefore, they can vary between accounts. For example, the Availability Zone us-east-1a for account A is not necessarily the same as us-east-1a for account B.
Note
You can use Availability Zones in conjunction with Elastic IP addresses to remap IP addresses across Availability Zones. For information about Elastic IP addresses, see Elastic IP Addresses in EC2-Classic (p. 467).
Description Describes the Availability Zones that are available to you. Describes the regions that are available to you.
Amazon Elastic Compute Cloud User Guide Regions and Availability Zones
3.
After you select a region, you can view your Availability Zones within that region when you launch an instance or create an Amazon EBS volume. a. b. c. Click Volumes in the Navigation pane. View the options in the Availability Zones list box. When you are finished, click Cancel.
Use the following command to describe the Availability Zones within the us-east-1 region.
PROMPT> > ec2-describe-availability-zones --region us-east-1 AVAILABILITYZONE us-east-1a available us-east-1 AVAILABILITYZONE us-east-1b available us-east-1 AVAILABILITYZONE us-east-1c available us-east-1 AVAILABILITYZONE us-east-1d available us-east-1
API
To find your regions Construct the following Query request to find your regions.
Amazon Elastic Compute Cloud User Guide Regions and Availability Zones
To find your Availability Zones Construct the following Query request to find your Availability Zones.
https://ec2.amazonaws.com/ ?Action=DescribeAvailabilityZones &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Regions and Availability Zones
running, consider not specifying an Availability Zone unless your new instances must be close to, or separated from, your existing instances.
API
Construct the following Query request to launch an instance in a specific Availability Zone.
https://ec2.amazonaws.com/ ?Action=RunInstances &ImageId=ami-id &MaxCount=1 &MinCount=1 &KeyName=keypair-name &Placement.AvailabilityZone=zone &AUTHPARAMS
Related Topics
Region and Availability Zone FAQ (p. 600)
Supported Platforms
Amazon EC2 supports the following platforms. Your AWS account is capable of launching instances either into both platforms or only into EC2-VPC, on a region by region basis.
Platform EC2-Classic
n t ire opc i D s r uoY satsi en c n nu r n i a ,elgis n tal f krote wn ta t h uo y era s h h t iw re to h .srts mu oc e r uoY satsi en c n nu r n i a latr iv u eta i r vp do l c u )C ( P V s' tat h yl ao lcg il dt loi eas o t r uoy SWA . tnc uc oa
EC2-VPC
EC2-VPC
The dashboard displays the following under Resources to indicate that the account supports only the EC2-VPC platform, and has a default VPC with the identifier vpc-1a2b3c4d.
If your account supports only EC2-VPC, you can select a subnet from the Subnet list when you launch an instance using the Classic wizard.
EC2-Classic, EC2-VPC
The dashboard displays the following under Resources to indicate that the account supports both the EC2-Classic and EC2-VPC platforms.
If your account supports EC2-Classic and EC2-VPC, you can use the EC2-Classic tab to launch an instance into EC2-Classic using the Classic wizard.
If your account supports EC2-Classic and EC2-VPC, you can use the EC2-VPC tab to select a subnet when you launch an instance into a VPC using the Classic wizard.
Related Topic
For more information about how you can tell which platforms you can launch instances into, see Detecting Your Supported Platforms in the Amazon Virtual Private Cloud User Guide.
For more information about the differences between EC2-Classic and EC2-VPC, see Amazon EC2 and Amazon Virtual Private Cloud (VPC) (p. 454).
means the root device for an instance launched from the AMI is an instance store volume created from a template stored in Amazon S3. After we introduced Amazon EBS, we introduced AMIs that are backed by Amazon EBS. This means that the root device for an instance launched from the AMI is an Amazon EBS volume created from an Amazon EBS snapshot. You can choose between Amazon EC2 instance store and Amazon EBS as the root device for your AMI. We recommend using AMIs backed by EBS, because they launch faster and use persistent storage.
After an EC2 instance store-backed instance fails or terminates, it cannot be restored. If you plan to use Amazon EC2 instance store-backed instances, we highly recommend that you distribute the data on your instance stores across multiple Availability Zones. You should also back up the data on your instance store volumes to Amazon S3 on a regular basis. Instances that use Amazon EBS for the root device automatically have an Amazon EBS volume attached. When an Amazon EBS-backed instance is launched, an EBS volume is created for each EBS snapshot referenced by the AMI. You must have at least one snapshot that denotes the root device; the others are optional and denote additional volumes to be created from other snapshots. An Amazon EBS-backed instance can be stopped and later restarted without affecting data stored in the attached volumes. There are various instance- and volume-related tasks you can do when an Amazon EBS-backed instance is in a stopped state. For example, you can modify the properties of the instance, you can change the size of your instance or update the kernel it is using, or you can attach your root volume to a different running instance for debugging or any other purpose.
By default, the root device volume and the other volumes created when an Amazon EBS-backed instance is launched are automatically deleted when the instance terminates (in other words, their DeleteOnTermination flags are set to true by default).You can change the default behavior by setting the DeleteOnTermination flag to the value you want when you launch the instance. For more information about how to change the flag at launch time, see Using Amazon EC2 Root Device Storage (p. 132). However, any EBS volumes that you attach after the instance is running (their DeleteOnTermination flags are set to false by default) are detached with their data intact on instance termination. These volumes can later be reattached to any running instance. If an Amazon EBS-backed instance fails, you can restore your session by following one of these methods: Stop and then start again. Automatically snapshot all relevant volumes and create a new AMI. For more information, see Creating Amazon EBS-Backed Linux AMIs (p. 35). Attach the volume to the new instance by following these steps: 1. Snapshot just the root volume. 2. Register a new AMI using the snapshot. 3. Launch a new instance from the new AMI. 4. Detach the remaining volumes from the old instance. 5. Reattach the volumes to the new instance.
We recommend using either the first or the second method for failed instances with normal volume size and the third method for failed instances with large volumes.
Launching an Amazon EBS-backed instance with increased root device storage disk size
1 Select an Amazon EBS-backed AMI to launch your instance from. 2 Check the root device size and note the AMI ID. 3 Using the command line interface, launch the instance by specifying the AMI ID and the mapping of the root device with the increased size. 4 Connect to the instance. 5 Check the size of the root device on the instance. The increased size of the root device is not apparent yet. This is because the file system does not recognize the increased size on the root device. 6 Resize the file system. 7 Check the size of the root device. 8 The root device of the newly launched instance now shows the increased size.
Note
You cannot decrease the size of your root device to less than the size of the AMI. To decrease the size of your root device, create your own AMI with the desired size for the root device and then launch an instance from that AMI.
Increasing the size of the root device on an Amazon EBS-backed running instance
1 Get the Amazon EBS volume ID and the Availability Zone of a running instance for which you want to increase the root storage size. Stop the instance. Detach the original volume from the instance. Create a snapshot of the detached volume. Create a new volume from the snapshot by specifying a larger size. Attach the new volume to the stopped instance. Start the instance and get the new IP address/hostname. Connect to the instance using the new IP address/hostname. Resize the root file system to the extent of the new Amazon EBS volume. Check the size of the root device. The root device now shows the increased size. [Optional] Delete the old EBS volume, if you no longer need it.
2 3 4 5 6 7 8 9 10 11
The following list describes the tasks for creating a snapshot of the root device of an Amazon EC2 instance store-backed instance. The snapshot is created using an Amazon EBS volume.You can use this snapshot to create a new EBS-backed AMI or to launch another instance.
Creating a snapshot of the root device of an Amazon EC2 instance store-backed instance
1 Launch an instance from an Amazon EC2 instance store-backed AMI. 2 Create a 10GiB Amazon EBS volume in the same Availability Zone as that of your newly launched instance.
Note
Use this volume to create a snapshot of the root partition of an Amazon EC2 instance store-backed AMI.The resulting snapshot is the same size as the root partition; the maximum size of the root partition in an Amazon EC2 instance store-backed AMI is 10GiB. 3 Attach the volume to the running instance using either the AWS Management Console or the command line tools. 4 Format the volume with a file system. 5 [For Linux Users] Create a directory and then mount the volume on the newly-created directory. 6 Copy the data on the root storage device to the newly-attached EBS volume. 7 Unmount and detach the volume from the instance. 8 Create a snapshot of the volume.
Amazon EC2 instance store-backed AMIs are limited to 10GiB storage for the root device. If you require additional storage on your root device, you must first convert the Amazon EC2 instance store-backed AMI to an Amazon EBS-backed AMI and then launch an EBS-backed instance with increased root storage.
Note
This conversion procedure works with a Linux AMI, but step 6 fails with a Windows AMI.
The root device is typically /dev/sda1, or xvda (for Windows). Following is an example.
ec2-run-instances ami-1a2b3c4d -v -b /dev/sda1=::false other parameters...
If you're using the command line tools on a Windows system, you must put quotation marks around the block device mapping value.
ec2-run-instances ami-1a2b3c4d -b "xvda=::false" other parameters... -v
By running the command in verbose mode, you can see the underlying SOAP request, and confirm that the deleteOnTermination value is set to false. The following XML snippet is from the SOAP request sent to Amazon EC2.
... <blockDeviceMapping> <item> <deviceName>/dev/sda1</deviceName> <ebs> <deleteOnTermination>false</deleteOnTermination> </ebs> </item> </blockDeviceMapping> ...
You can also verify the setting after the instance launches by viewing the instance's details in the AWS Management Console.
You can confirm the setting by using DescribeInstances. The following example snippet from the XML response shows that the flag is set to false for the instance's root device.
... <rootDeviceName>/dev/sda1</rootDeviceName> <blockDeviceMapping> <item> <deviceName>/dev/sda1</deviceName> <ebs> <volumeId>vol-818843e8</volumeId> <status>attached</status> <attachTime>2010-02-22T20:36:18.000Z</attachTime> <deleteOnTermination>false</deleteOnTermination> </ebs> </item> </blockDeviceMapping> ...
You can also verify the setting by viewing the instance's details in the AWS Management Console. For more information, see Viewing Block Device Mappings (p. 548).
customize as necessary. Specialized images can result in smaller AMI sizes, which boot considerably faster. Monitor the health of your instances. For more information, go to the Amazon CloudWatch product page. Keep your Amazon EC2 firewall permissions as restrictive as possible. Only open up permissions that you require. Use separate security groups to deal with instances that have different security requirements. Consider using additional security measures inside your instance (such as using your own firewall). If you need to log in interactively (SSH), consider creating a bastion security group that allows external login and keep the remainder of your instances in a group that does not allow external login. For more information about security groups, see Amazon EC2 Security Groups (p. 426).
Spot Instances
If you have flexibility on when your application will run, you can bid on unused Amazon EC2 compute capacity, called Spot Instances, and lower your costs significantly. Set by Amazon EC2, the Spot Price for these instances fluctuates periodically depending on the supply of and demand for Spot Instance capacity. To use Spot Instances, you place a Spot Instance request (your bid) specifying the maximum price you are willing to pay per hour per instance. If the maximum price of your bid is greater than the current Spot Price, your request is fulfilled and your instances run until you terminate them or the Spot Price increases above your maximum price. Your instance can also be terminated when your bid price equals the market price, even when there is no increase in the market price. This can happen when demand for capacity rises, or when supply fluctuates. You will often pay less per hour than your maximum bid price. The Spot Price is adjusted periodically as requests come in and the available supply of instances changes. Everyone pays that same Spot Price for that period regardless of whether their maximum bid price was higher, and you will never pay more than your hourly maximum bid price.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
If you are new to Spot Instances, take a look at Prerequisites for Using Spot Instances (p. 136) to make sure you can take full advantage of the benefits of this Amazon EC2 product. If you have been using Amazon EC2 and you're ready to look into making a Spot Instance request, proceed to one of the following steps: Viewing Spot Price History (p. 139) Creating a Spot Instance Request (p. 142) Finding Running Spot Instances (p. 147) Canceling Spot Instance Requests (p. 150) Advanced Tasks (p. 180)
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Spot Instance Pricing History gives you an insight in the pricing patterns for specific Spot Instance types in Availability Zones over a defined period.
Use the Request Spot Instances page to specify the details of instances to be launched when your Spot Instance bid succeeds.
Use the Instances page to manage the instances launched when your Spot Instance bid succeeds.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Task Viewing Spot Price History (p. 139). Finding Running Spot Instances (p. 147). Creating a Spot Instance Request (p. 142).
CLI
ec2-describe-spot-price-history ec2-describe-spot-instance-requests ec2-request-spot-instances
Subscribe to Your Spot Instance Data Feed (p. 182). ec2-create-spot-datafeed-subscription Data Feed Filename and Format (p. 181). Delete a Spot Instance Data Feed (p. 183). Canceling Spot Instance Requests (p. 150).
ec2-describe-spot-datafeed-subscription ec2-delete-spot-datafeed-subscription ec2-cancel-spot-instance-requests
For information about CLI commands, go to the Amazon Elastic Compute Cloud Command Line Reference.
API
To manage your Spot Requests, you use Amazon EC2 API tools specifically designed for these tasks. To manage the instances launched when your Spot Request is fulfilled, use the same API actions that you use for Amazon EC2 instances. The following table lists the API actions you use for Spot Request tasks. Task Viewing Spot Price History (p. 139). Finding Running Spot Instances (p. 147). Creating a Spot Instance Request (p. 142). API
DescribeSpotPriceHistory DescribeSpotInstanceRequests RequestSpotInstances
Subscribe to Your Spot Instance Data Feed (p. 182). CreateSpotDatafeedSubscription Data Feed Filename and Format (p. 181). Delete a Spot Instance Data Feed (p. 183). Canceling Spot Instance Requests (p. 150).
DescribeSpotDatafeedSubscription DeleteSpotDatafeedSubscription CancelSpotInstanceRequests
For information about API actions, go to the Amazon Elastic Compute Cloud API Reference.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Note
Make sure you have set up the prerequisites to working with Amazon EC2. If you haven't, go to Prerequisites for Using Spot Instances (p. 136).
Note
Using the historical pricing as a guide, select a price that you think would be likely to keep your instances running for the period of time you need. 3. If you want to view the Spot Price history for specific Availability Zones, click the Zone drop-down list and select an Availability Zone. The Spot Instance Pricing History page displays the Spot Instance pricing history for the zone you selected.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
2011-04-18T14:39:14-0800 2011-04-18T14:39:14-0800
m1.xlarge m1.xlarge
SUSE SUSE
In this example, the price for the m1.xlarge instance type ranges between $0.242 and $0.384. 2. Based on the historical pricing, select a price that is likely to keep your instances running for the period of time that you need.
Tip
You can filter the spot history data so it includes only instance types or dates of interest to you. For more information about how to filter the results, go to ec2-describe-spot-price-history in the Amazon Elastic Compute Cloud Command Line Reference.
API
To view Spot Price history
Construct the following Query request.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Note
Based on the historical pricing, select a price that is likely to keep your instances running for the period of time that you need.
Tip
You can filter the spot history data so it includes only instance types or dates of interest to you. For more information about how to filter the results, go to DescribeSpotPriceHistory in the Amazon Elastic Compute Cloud API Reference. What do you want to do next? Creating a Spot Instance Request (p. 142) Finding Running Spot Instances (p. 147) Bidding Strategies (p. 153) Launching Spot Instances in Amazon Virtual Private Cloud (p. 178)
For information about creating AMIs, see Creating Your Own AMIs (p. 34).
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Important
Although Spot Instances can use Amazon EBS-backed AMIs, be aware that the EBS-backed AMIs don't support Stop/Start. In other words, you can't stop and start Spot Instances launched from an AMI with an Amazon EBS root device.
Note
When you use the DescribeSpotPriceHistory action or the ec2-describe-spot-price-history command before the 2011-05-15 API version, you will get the lowest price across the Region for the given time period and the prices will be returned in chronological orderthat is, from the oldest to the most recent. For more information about Availability Zones, see Region and Availability Zone Concepts (p. 119).
Note
Make sure you have set up the prerequisites for working with Amazon EC2. If you haven't, go to Prerequisites for Using Spot Instances (p. 136).
API Version 2013-02-01 143
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
4.
Specify the number and type of instances you want, and the desired Availability Zone (if any).
Note
Current Price displays the price for the Availability Zone you specified. If you do not specify an Availability Zone, Current Price displays the lowest price across all Availability Zones. The information displayed when the cursor hovers over the Current Price shows the price for each of the Availability Zones. 5. Configure the Spot Instance settings using the following table as a guide, and then click Continue. Option Max Price Description Specifies the maximum price you are willing to pay per instance hour. Defines the validity period of a Spot Request. The valid period, beginning with Request Valid From through Request Valid Until, specifies the length of time that your request will remain valid. By default, a Spot Request will be considered for fulfillment from the time it is created until it is either fulfilled or canceled by you. However, you can constrain the validity period using these options.
Note
The end time you specify doesn't apply to the Spot Instances launched by this request. This end time only applies to the Spot Instance request.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Description Determines whether your request is one-time or persistent. By default, it is one-time. A one-time request can only be fulfilled once. A persistent request is considered for fulfillment whenever there is no Spot Instance running for the same request. Groups a set of requests together in the same launch group. All requests in a launch group have their instances started and terminated together. Groups a set of requests together in the same Availability Zone. All requests that share an Availability Zone group will launch Spot Instances in the same Availability Zone.
Launch Group
6.
Continue with the launch wizard as you normally would when launching instances. If your request specified multiple instances, EC2 creates a separate Spot Instance request for each instance. The requests are displayed on the Spot Requests page.
For example:
PROMPT> ec2-request-spot-instances --price 0.32 ami-1234abcd --key MyKeypair --group websrv --instance-type m1.small --instance-count 10 --type one-time
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
If your request specified multiple instances, EC2 creates a separate Spot Instance request for each instance; each instance has a different ID (e.g., sir-09fb0a04).
API
To create a Spot Price request
Construct a Query request similar to the following.
https://ec2.amazonaws.com/ ?Action=RequestSpotInstances &SpotPrice.1=0.50 &InstanceCount.1=10 &Type.1=one-time &AvailabilityZoneGroup.1=MyAzGroup &LaunchSpecification.ImageId.1=ami-43a4412a &LaunchSpecification.KeyName.1=MyKeypair &LaunchSpecification.GroupSet.1=websrv &LaunchSpecification.InstanceType.1=m1.small &...auth parameters...
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
If your request specified multiple instances, EC2 creates a separate Spot Instance request for each instance; each instance has a different ID (e.g., sir-876aff12). What do you want to do next? Finding Running Spot Instances (p. 147) Canceling Spot Instance Requests (p. 150) Planning for Interruptions (p. 160) Bidding Strategies (p. 153) Launching Spot Instances in Amazon Virtual Private Cloud (p. 178) Tagging Spot Instance Requests (p. 159) Subscribe to Your Spot Instance Data Feed (p. 180)
Important
Although Spot Instances can use Amazon EBS-backed AMIs, be aware that the EBS-backed AMIs don't support Stop/Start. In other words, you can't stop and start Spot Instances launched from an AMI with an Amazon EBS root device.
Note
Make sure you have set up the prerequisites for working with Amazon EC2. If you haven't, go to Prerequisites for Using Spot Instances (p. 136).
2.
Look for instances in the table where the Lifecycle column contains spot. You might need to turn on the display of the column (click Show/Hide in the top right corner of the page).
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
PROMPT> ec2-describe-spot-instance-requests SPOTINSTANCEREQUEST sir-e1471206 0.09 active 2010-09-13T16:50:44-0800 i-992cf7dd ami-813968c4 m1.small monitoring-disabled
Linux/UNIX
You can alternately use ec2-describe-instances with the following filter: --filter instance-lifecycle=spot. If you're using the command line tools on a Windows system, you might need to use quotation marks (--filter "instance-lifecycle=spot"). For more information about filters, see Listing and Filtering Your Resources (p. 562).
PROMPT> ec2-describe-instances --filter instance-lifecycle=spot
API
To find running Spot Instances
1. Construct a DescribeInstances Query request and use a filter to look for instances where instance-lifecycle=spot. For more information about filters, see Listing and Filtering Your Resources (p. 562).
https://ec2.amazonaws.com/ ?Action=DescribeInstances &Filter.1.Name=instance-lifecycle &Filter.1.Value.1=spot &...auth parameters...
Following is an example response. It includes an instanceLifecycle element with spot as the value.
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> ... <instancesSet> <item> <instanceId>i-992cf7dd</instanceId> <imageId>ami-813968c4</imageId> <instanceState> <code>16</code> <name>running</name> </instanceState> <privateDnsName>ip-10-166-105-139.us-west-1.compute.internal</privateDns
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Name> <dnsName>ec2-184-72-8-111.us-west-1.compute.amazonaws.com</dnsName> <reason/> <keyName>MyKey</keyName> <amiLaunchIndex>0</amiLaunchIndex> <productCodes/> <instanceType>m1.small</instanceType> <launchTime>2010-09-13T23:54:40.000Z</launchTime> <placement> <availabilityZone>us-west-1a</availabilityZone> <groupName/> </placement> <kernelId>aki-a13667e4</kernelId> <ramdiskId>ari-a33667e6</ramdiskId> <monitoring> <state>disabled</state> </monitoring> <privateIpAddress>10.166.105.139</privateIpAddress> <ipAddress>184.72.8.111</ipAddress> <architecture>i386</architecture> <rootDeviceType>ebs</rootDeviceType> <rootDeviceName>/dev/sda1</rootDeviceName> <blockDeviceMapping> <item> <deviceName>/dev/sda1</deviceName> <ebs> <volumeId>vol-61088f0a</volumeId> <status>attached</status> <attachTime>2010-09-13T23:54:42.000Z</attachTime> <deleteOnTermination>true</deleteOnTermination> </ebs> </item> </blockDeviceMapping> <instanceLifecycle>spot</instanceLifecycle> <spotInstanceRequestId>sir-e1471206</spotInstanceRequestId> <virtualizationType>paravirtual</virtualizationType> </item> </instancesSet> </DescribeInstancesResponse>
2.
You can alternately use DescribeSpotInstanceRequests. If your Spot Instance request has been fulfilled (an instance has been launched), the instance ID appears in the response. Following is an excerpt from a response.
... <spotInstanceRequestSet> <item> <spotInstanceRequestId>sir-e1471206</spotInstanceRequestId> <spotPrice>0.09</spotPrice> <type>one-time</type> <state>active</state> <launchSpecification> <imageId>ami-813968c4</imageId> <keyName>MyKey</keyName> <groupSet> <item>
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
<groupId>default</groupId> </item> </groupSet> <instanceType>m1.small</instanceType> <blockDeviceMapping/> <monitoring> <enabled>false</enabled> </monitoring> </launchSpecification> <instanceId>i-992cf7dd</instanceId> <createTime>2010-09-13T23:50:44.000Z</createTime> <productDescription>Linux/UNIX</productDescription> <launchedAvailabilityZone>us-east-1c</launchedAvailabilityZone> </item> <spotInstanceRequestSet/> ...
What do you want to do next? Canceling Spot Instance Requests (p. 150) Planning for Interruptions (p. 160) Bidding Strategies (p. 153) Launching Spot Instances in Amazon Virtual Private Cloud (p. 178) Persist Your Root EBS Partition (p. 161) Tagging Spot Instance Requests (p. 159) Subscribe to Your Spot Instance Data Feed (p. 180)
Note
The Valid Until option that you specify when you submit a Spot Instance request applies only to the request; this deadline doesn't apply to Spot Instances that are launched by the request.
After placing a request, you can check its state and the state of your other requests.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
Note
Make sure you have set up the prerequisites for working with Amazon EC2. If you haven't, go to Prerequisites for Using Spot Instances (p. 136).
2. Select the spot instances you want to cancel and click the Cancel Request button.
2010-04-06T10:03:09+0200 monitoring-disabled
ami-b232d0db
Tip
You can filter the list of Spot Instance requests to return only certain types of interest to you. For more information about how to filter the results, go to ec2-describe-spot-instance-requests in the Amazon Elastic Compute Cloud Command Line Reference.
Amazon Elastic Compute Cloud User Guide Getting Started with Spot Instances
API
To cancel Spot Instance requests
1. Construct the following Query request.
https://ec2.amazonaws.com/ ?Action=DescribeSpotInstanceRequests &...auth parameters...
2.
Tip
You can filter the list of Spot Instance requests to return only certain types of interest to you. For more information about how to filter the results, go to DescribeSpotInstanceRequests in the Amazon Elastic Compute Cloud API Reference. What do you want to do next? Creating a Spot Instance Request (p. 142) Viewing Spot Price History (p. 139) Finding Running Spot Instances (p. 147) Launching Spot Instances in Amazon Virtual Private Cloud (p. 178)
Fundamentals
If your application can tolerate interruptions and can handle dynamically changing compute capacity and prices, Amazon EC2 Spot Instances can be powerful tool for optimizing your applications costs and increasing its computational scale. This section presents foundational concepts to help you create successful Spot requests and use Spot Instances effectively. A Spot bid defines the kind of Spot Instances you want and the maximum price you're willing to pay for them. The definition of your bid can determine the fulfillment of the request and the successful launch of Spot Instances. For information, see Placing Spot Bids (p. 153). You can use tags to manage your Spot Instances. For information, see Tagging Spot Instance Requests (p. 159). The availability of Spot Instances varies significantly depending on Amazon EC2 capacity. When you use Spot Instances, you plan for interruptions and mitigate their effect on your applications. For information, see Protecting Your Spot Instance Data Against Interruptions (p. 160).
Bidding Strategies
Depending on how soon you want your Spot Instance request fulfilled and how long you want your Spot Instances to continue running, there are a number of factors you need to consider when you make a bid for Spot Instances. The requirements you include in your Spot Instance request can affect the chances
that it will be fulfilled. If you have a number of requirements that must be met, your request can take a little longer to fulfill. The maximum Spot Instance price impacts bid fulfillment and how long your Spot Instances run, as well. If you want your instances to run continuously for longer periods, select a higher price. If your instances don't need to run continuously, select a lower price. The maximum Spot Instance price you specify is not necessarily the price that you pay. For example, if you specify $.50 as your maximum price, and the Spot Price is $.30 for the period, you pay $.30. If the Spot Price drops, you pay less. If the Spot Price increases, you pay the new price (up to your specified maximum price).
Note
A bid is a request that is conditionally tied to a price. The terms are used interchangeably in this documentation. You can use any of the Amazon EC2 Spot Instance tools to obtain status information about your Spot requests. Spot bid status information will be available for new Spot requests as well as bid requests that you already have open. However, if you're using either the Amazon EC2 CLI or API tools to obtain bid status information, you need to use version 2012-10-01 or later of the API tools. The following table summarizes how you can get bid status information using the Amazon EC2 tools. Tool Spot Requests page in the Amazon EC2 console Amazon EC2 CLI Use Status column Bottom pane, tooltip To get Status code Status message
ec2-request-spot-instances Status code, status message, or and update time ec2-describe-spot-instance-requests RequestSpotInstances or
When you request a Spot Instance, your request goes through an evaluation process. At each step of the processalso called the Spot request life cyclespecific events dictate successive request states. In the life cycle diagram, each step is depicted as a node, and each node's status code describes the status of your Spot request and Spot Instance. 1. Pending evaluation As soon as you make your Spot Instance request, it goes into the pending-evaluation state. Status Code
pending-evaluation
The only reason your Spot bid request does not proceed to this pending-evaluation state is that at least one of the parameters is invalid (bad-parameters). Status Code
bad-parameters
2. Pending evaluation holding state Your Spot Instance request will report a status code in the holding state if one or more options you specified are valid but not met, or if we encounter a Spot capacity constraint. The options defined by your request affect the likelihood of it being fulfilled. For example, if you specified a max bid price below the current Spot price, or requested that your Spot Instances be launched together in one Availability Zone (AZ), your Spot request will stay in a holding state until the Spot price goes below your bid or the Availability Zone constraint is met.
The following table lists the status codes reported when your bid is in a holding state waiting for a constraint to be met. Status Code
capacity-not-available capacity-oversubscribed price-too-low not-scheduled-yet launch-group-constraint az-group-constraint
Instance State (none) (none) (none) (none) (none) (none) (none) (none)
3. Pending evaluation/fulfillment terminal state Before your request reaches the pending fulfillment phase, your Spot Instance request may end up in a terminal state if the valid dates you specified for the bid expired, you canceled the bid yourself, or a system error occurred.
Note
A canceled Spot request does not necessarily mean that the Spot Instance is terminated. In contrast, a closed Spot request means the request will no longer be considered and the Spot Instance is terminated. The following table lists the status codes reported when your bid ends up in the terminal state after pending evaluation or pending fulfillment. Status Code
schedule-expired
failed closed
* This status results from a cancellation initiated by a user. 4. Pending fulfillment When the constraints you specified (if any) are met, and your bid price is equal to or higher than the current Spot market price, your Spot request goes into the pending-fulfillment state. Status Code
pending-fulfillment
At this point, the Amazon EC2 Spot service is getting ready to provision the instances that you requested. If the process stops at this point, it would likely be due to cancellation by the user before a Spot Instance was launched, or an unexpected system error (see Pending evaluation/fulfillment terminal state).
5. Fulfilled When all the specifications for your Spot Instance are met, your Spot request is fulfilled. The Amazon EC2 Spot service launches the Spot Instance, which may take a few minutes. Status Code
fulfilled
At this point, your instance launches, and your bid request is active. Your instance will continue to run as long as your bid price is at or above the Spot market price, EC2 has spare Spot capacity for your instance type, and you don't terminate the instance.
Note
If your bid price is equal to the market price, your request can stay fulfilled, but you run the risk of your Spot Instance getting terminated at any time that the market price goes up. In some cases, your Spot Instance could be evicted even if your bid equaled the Spot price because Spot Instances were oversubscribed at that price. In such cases, you will get the instance-terminated-capacity-oversubscribed status code. See Fulfilled terminal state. 6. Fulfilled terminal state Your Spot request will report a status code in the terminal state if a change in Spot price or capacity requires the Spot service to terminate your Spot Instance. You will also get a terminal state status code if you cancel the Spot request or terminate the Spot Instance. The following table lists the status codes reported when your instance is in the terminal state after the bid was fulfilled. Status Code Request State Instance State running running (Spot) terminated terminated[c]
closed
instance-terminated-by-price closed[a] instance-terminated-by-user closed[b] (or spot-instance-terminated-by-user, which will be deprecated) instance-terminated-no-capacity closed[a] i s a c - e m n t d c p c t - v r u s r b d closed[a] ntnetriae-aaiyoesbcie i s a c - e m n t d l u c - r u - o s r i t closed[a] ntnetriae-anhgopcntan
[a] If the Spot bid request is persistent, the state of the request becomes open. See the next item, Persistent requests. [b] If you terminate your instance first, there may be a delay before the Spot service realizes that your Spot Instance was terminated. For persistent requests, this means that for user-terminated instances it could take some time before your Spot request re-enters the pending-evaluation state. [c] Actions are initiated by the user. 7. Persistent requests When your Spot Instances are terminated (either by you or the Amazon EC2 Spot service), if you specified a persistent Spot request, then the request will be considered again. This request returns to the pending-evaluation state.Your Spot bid request will undergo the same evaluation process that it originally went through, and an entirely new Spot Instance will be launched for the persistent Spot request.
API Version 2013-02-01 157
Note
The status codes instance-terminated-by-user and spot-instance-terminated-by-user represent the same status. The code spot-instance-terminated-by-user will be deprecated. instance-terminated-by-price The Spot price rose above your bid price. If your request is a persistent bid, the processor life cyclerestarts and your bid will again be pending evaluation. instance-terminated-capacity-oversubscribed Your instance was terminated because the number of Spot requests with bid prices equal to or higher than your bid price has exceeded the available capacity in this pool. This means that your instance was interrupted even though the Spot price may not have changed because your bid was at the Spot price.
Note
When there are several requests at a certain bid price and only some of them need to be terminated, the Spot service randomly selects the requests to be terminated. instance-terminated-launch-group-constraint One of the instances in your launch group was terminated, so the launch group constraint is no longer fulfilled.
API Version 2013-02-01 158
instance-terminated-no-capacity There is no longer any Spot capacity available for the instance. launch-group-constraint The Spot service cannot launch all the instances you requested at the same time. marked-for-termination Your Spot Instance is marked for termination. not-scheduled-yet Your Spot request will not be evaluated until the scheduled date. pending-evaluation As soon as you make your Spot Instance request, it goes into the pending-evaluation state while the system evaluates the parameters of your request. pending-fulfillment Your Spot request is pending fulfillment while the system tries to provision your Spot Instance. placement-group-constraint Your Spot request cannot be fulfilled yet because a new Spot Instance cannot currently be added to the placement group you specified. price-too-low You have a bid request that cannot be fulfilled because the bid price is below the Spot price. In this case, no instance is launched, and your bid remains open. request-canceled-instance-running You canceled your Spot request while the Spot instance was still running, so the request is canceled, but the instance remains running. schedule-expired Your Spot request has expired because it was not fulfilled before the valid to date. system-error There was an unexpected system error. If this is a recurring issue, please contact customer support for assistance.
You can also confirm the tag information by using the ec2-describe-tags command. When your request is fulfilled and a Spot Instance launches, you will see that the tag you used for your Spot Instance request is not applied to the Spot Instance. In the following example command, we are obtaining information about the Spot Instance i-b8ca48d8 that was launched as a result of your Spot Instance request sir-69047e11, tagged Spot=Test.
PROMPT> ec2-describe-instances i-b8ca48d8
The call returns details about the instance with no tag information, showing that the tag for your Spot Instance request does not apply to the Spot Instance that the request launched. To tag your Spot Instance, use the following command:
PROMPT> ec2-create-tags i-b8ca48d8 --tag "SpotI=Test1"
You can create similar tags using the API. For more information, see the API section of Using Tags in the Amazon Elastic Compute Cloud User Guide.
Note
No matter how high you bid, there is always a risk that your Spot Instance will be interrupted. We strongly recommend against bidding above the On-Demand price or using Spot for applications that cannot tolerate interruptions. The following sections discuss how to plan for and mitigate the impact of interruptions. Planning for Interruptions (p. 160) Persist Your Root EBS Partition (p. 161)
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Important
Although Spot Instances can use Amazon EBS-backed AMIs, be aware that the EBS-backed AMIs don't support Stop/Start. In other words, you can't stop and start Spot Instances launched from an AMI with an Amazon EBS root device. To set up the persistence of Spot Instance data, you map the Spot Instances that will be launched to an existing Amazon Elastic Block Store (Amazon EBS) snapshot. Set the delete-on-termination flag to false; this indicates that Amazon EC2 shouldn't delete the Amazon EBS volume when the spot instance terminates. Let's walk through making an example Spot Request with the following specifications: Bid price of $0.5 One instance of the m1.xlarge instance type Block device mapping to a snapshot that shouldn't be deleted when the Spot Instance is terminated
You can do this example using either the CLI or API tools. Using the CLI, your example request should look like this:
PROMPT> ec2-request-spot-instances -p 0.5 -t m1.xlarge -n 1 -b '/dev/sdb=snapa123bcde:20:false' ami-8e1fece7
For more information, see: Block Device Mapping (p. 545) ec2-request-spot-instances RequestSpotInstances
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Launching Amazon Elastic MapReduce Job Flows with Spot Instances (p. 178) Launching Spot Instances in Amazon Virtual Private Cloud (p. 178) You can use AWS services with Spot Instances. In this section, we will show you how Amazon EC2 Spot Instances works with services, such as Auto Scaling, Elastic MapReduce, and Amazon Virtual Private Cloud (Amazon VPC).
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Persistent bids. Auto Scaling will continue submitting bids for you as long as you keep your Auto Scaling group and launch configuration. The Auto Scaling group specifies the desired number of instances you want maintained and the launch configuration specifies the bid price for your Spot Instances. For more information about Auto Scaling, see Auto Scaling Developer Guide. To get started quickly with Auto Scaling, see Get Started with Auto Scaling.
Setup and Install Auto Scaling command line tools Using the Command Line Tools in the Auto Scaling Developer Guide. Read the readme installation instructions Install Drive\AutoScaling-n.n.nn.n\README
Description Creates a new launch configuration with specified attributes. Creates a new Auto Scaling group with specified name and other attributes.
as-create-auto-scaling-group
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Command
as-describe-auto-scaling-groups
Description Describes the Auto Scaling groups, if the groups exist. Describes the Auto Scaling instances, if the instances exist. Describes a set of activities or all activities belonging to a group. Deletes the specified auto scaling group, if the group has no instances and no scaling activities are in progress.
as-describe-auto-scaling-instances
as-describe-scaling-activities
as-delete-auto-scaling-group
4.
For common conventions the documentation uses to represent command symbols, see Document Conventions. Type as-command-name --help. The command line returns a description, syntax information, and examples of how to use the specified Auto Scaling CLI command.
For Amazon EC2 CLI tools, see the following: Amazon EC2 CLI tools. Amazon Elastic Compute Cloud CLI Reference in the Amazon EC2 Command Line Reference. Amazon EC2 CLI tools specific to Spot Instances. Command Line Tools (p. 137) in the Amazon EC2 User Guide. Other Amazon EC2 tools you can use with Spot instances. Getting Started with Spot Instances (p. 136) in the Amazon EC2 User Guide.
Prerequisites
If you're not familiar with how to create a launch configuration or an Auto Scaling group, we recommend that you go through the steps in the Basic Scenario in Auto Scaling in the Auto Scaling Developer Guide. Use the basic scenario to get started with the infrastructure that you need in most Auto Scaling scenarios. If you don't have the Auto Scaling CLI tools installed on your computer, you must install them to do this walkthrough. For information, go to Auto Scaling Tools You Will Use in the Amazon EC2 User Guide. You can also use the information in Using the Command Line Tools in the Auto Scaling Developer Guide. In this scenario, we will perform the following tasks: Step 1: Create a Launch Configuration (p. 165) Step 2: Create an Auto Scaling Group (p. 166)
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
If you already have a launch configuration and Auto Scaling group, here are other related Spot Instance tasks that you can do using Auto Scaling: Updating the Bid Price for the Spot Instances (p. 171) Scheduling Spot Bid Requests (p. 173) Using Auto Scaling to Get Notifications for Spot Instances (p. 174) Advanced Tasks (p. 180)
For more information about Auto Scaling, see Understanding Auto Scaling in the Auto Scaling Developer Guide. For information about scenarios using Auto Scaling, see Using Auto Scaling also in the Auto Scaling Developer Guide.
The only required options are the launch configuration name, image ID, and instance type. For this walkthrough, specify: Launch configuration name = spotlc-5cents
Note
When Auto Scaling launches instances, it does not distinguish the Spot Instances from the On-Demand instances. To help you identify which of your instances are Spot Instances, consider assigning a launch configuration name that includes spot and the bid price. Image ID = ami-e565ba8c The Image ID identifies the Amazon Machine Image (AMI) that will be used to launch the instances. If you don't have an AMI, and you want to find a suitable one, see Amazon Machine Images (AMIs). Instance type = m1.small Spot price = $0.05 This parameter is optional. If you want to launch Spot Instances, you must specify the Spot bid price that will be used to bid for Spot Instances. Spot Instance bid prices must be specified in US dollars.
API Version 2013-02-01 165
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
This command requires that you specify a name for your Auto Scaling group, a launch configuration, one or more Availability Zones, a minimum group size, and a maximum group size. The Availability Zones you choose determine the physical location of your Auto Scaling instances. The minimum and maximum group size tells Auto Scaling the minimum and maximum number of instances the Auto Scaling group should have. Desired capacity is an important component of the as-create-auto-scaling-group command. Although it is an optional parameter, desired capacity tells Auto Scaling the number of instances you want to run initially. To adjust the number of instances you want running in your Auto Scaling group, you change the value of --desired-capacity. If you don't specify --desired-capacity, its value is the same as minimum group size. For more detailed information on the syntax of the as-create-auto-scaling-group command, see Create an Auto Scaling Group in the Auto Scaling Developer Guide. You can also get help information from the command line: Run the as-create-auto-scaling-group --help. For more information, go to Resources for Using Auto Scaling CLI Tools (p. 163). For this walkthrough, specify these values for the command: Auto Scaling Group name = spotasg
Note
When Auto Scaling launches instances, it does not distinguish the Spot Instances from the On-Demand instances. To help you identify which of your instances are Spot Instances, consider assigning spot-specific names to the Auto Scaling group that launches Spot Instances. Launch configuration name = spotlc-5cents Availability Zone = us-east-1a,us-east-1b Max size = 5 Min size = 1 Desired capacity = 3
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
What do you want to do next? Obtaining Information About the Instances Launched by Auto Scaling (p. 167) Updating the Bid Price for the Spot Instances (p. 171) Scheduling Spot Bid Requests (p. 173) Using Auto Scaling to Get Notifications for Spot Instances (p. 174) Advanced Tasks (p. 180)
For more information about Auto Scaling, see Understanding Auto Scaling in the Auto Scaling Developer Guide. For information about scenarios using Auto Scaling, see Using Auto Scaling also in the Auto Scaling Developer Guide.
To check the status of the bids that Auto Scaling is making for you
The as-describe-scaling-activities command lists the activities that Auto Scaling performed for a specified Auto Scaling group. This is the basic syntax:
as-describe-scaling-activities [ActivityIds [ActivityIds ...]] [--auto-scaling-group value] [--max-records value] [General Options]
Specifying the Auto Scaling group and the Activity ID are optional. If you don't specify the Auto Scaling group, the command will return all activities for all Auto Scaling groups associated with your account. If you specify the Auto Scaling group, only the activities for that Auto Scaling group will be listed. In this scenario, we are using the as-describe-scaling-activities command to see state of your bid. Assume that there is only one Auto Scaling group (spotasg) and you want to list all activities.
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
1. 2.
Open a command line and navigate to the bin folder of your Auto Scaling CLI tools directory. Type the command: as-describe-scaling-activities --auto-scaling-group spotasg --headers The information you get should be similar to the following example.
ACTIVITY ACTIVITY-ID END-TIME GROUPNAME CODE MESSAGE ACTIVITY 31bcbb67-7f50-4b88-ae7e-e564a8c80a90 spotasg WaitingForSpotInstanceId Placed Spot instance request: sir-fc8a3014. Waiting for instance(s) ACTIVITY 770bbeb5-407c-404c-a826-856f65db1c57 spotasg WaitingForSpotInstanceId Placed Spot instance request: sir-69101014. Waiting for instance(s) ACTIVITY 597e4ebd-220e-42bc-8ac9-2bae4d20b8d7 2012-05-23T17:40:22Z spotasg Successful
In this response, you know that your bids were placed, one of the bids is successful, and Auto Scaling is waiting for the other two bids.
Note
If the as-describe-scaling-activities command returns a list that includes Failed activities, check the data you specified in the launch configuration. For example: The Amazon Machine Image (AMI) might not be valid anymore. The bid price specified in the launch configuration is lower than the Spot market price.
3.
If you run the as-describe-scaling-activities command again later, you can be getting information that is similar to the following example:
ACTIVITY ACTIVITY-ID NAME CODE ACTIVITY 90630906-b40f-41a6-967a-cd6534b2dfca Successful ACTIVITY a1139948-ad0c-4600-9efe-9dab8ce23615 Successful ACTIVITY 33001e70-6659-4494-a817-674d1b7a2f58 Successful END-TIME 2012-06-01T02:32:15Z 2012-06-01T00:48:02Z 2012-06-01T02:31:11Z GROUPspotasg spotasg spotasg
The output shows that the listed activities were successful. Because we know that spotasg is an Auto Scaling group that uses a launch configuration with a spot bid price, you can assume that the activities represent the bids placed by Auto Scaling. 4. If you want to get more details about the activities and instances, use the --show-xml option of as-describe-scaling-activities. Enter the following command as-describe-scaling-activities --auto-scaling-group spotasg --show-xml. The information you get should be similar to the following example.
<DescribeScalingActivitiesResponse xmlns="http://autoscaling.amazon aws.com/doc/2011-01-01/"> <DescribeScalingActivitiesResult> <NextToken>b5a3b43e-10c6-4b61-8e41-2756db1fb8f5</NextToken> <Activities> <member>
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
<StatusCode>Successful</StatusCode> <Progress>0</Progress> <ActivityId>90630906-b40f-41a6-967a-cd6534b2dfca</ActivityId> <StartTime>2012-06-01T00:48:21.942Z</StartTime> <AutoScalingGroupName>spotasg</AutoScalingGroupName> <Cause>At 2012-06-01T00:48:21Z a difference between desired and ac tual capacity changing the desired capacity, increasing the capacity from 2 to 3.</Cause> <Details>{}</Details> <Description>Launching a new EC2 instance: i-fe30d187</Description> <EndTime>2012-06-01T02:32:15Z</EndTime> </member> <member> <StatusCode>Successful</StatusCode> <Progress>0</Progress> <ActivityId>a1139948-ad0c-4600-9efe-9dab8ce23615</ActivityId> <StartTime>2012-06-01T00:47:51.293Z</StartTime> <AutoScalingGroupName>spotasg</AutoScalingGroupName> <Cause>At 2012-06-01T00:47:51Z an instance was taken out of service in response to a system health-check.</Cause> <Details>{}</Details> <Description>Terminating EC2 instance: i-88ce28f1</Description> <EndTime>2012-06-01T00:48:02Z</EndTime> </member> <member> <StatusCode>Successful</StatusCode> <Progress>0</Progress> <ActivityId>33001e70-6659-4494-a817-674d1b7a2f58</ActivityId> <StartTime>2012-06-01T00:46:19.723Z</StartTime> <AutoScalingGroupName>spotasg</AutoScalingGroupName> <Cause>At 2012-06-01T00:46:19Z a difference between desired and ac tual capacity changing the desired capacity, increasing the capacity from 2 to 3.</Cause> <Details>{}</Details> <Description>Launching a new EC2 instance: i-2c30d155</Description> <EndTime>2012-06-01T02:31:11Z</EndTime> </member> ... </Activities> </DescribeScalingActivitiesResult> <ResponseMetadata> <RequestId>d02af4bc-ad8f-11e1-85db-83e1968c7d8d</RequestId> </ResponseMetadata> </DescribeScalingActivitiesResponse>
The XML output shows more detail about the Spot and Auto Scaling activity. Cause: At 2012-06-01T00:48:21Z a difference between desired and actual capacity changing the desired capacity, increasing the capacity from 2 to 3. Description: Launching a new EC2 instance: i-fe30d187 If an instance is terminated and the number of instances falls below the desired capacity, Auto Scaling will launch a new instance so that the total number of your running instances rises back to the level specified for desired capacity.
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Cause: At 2012-06-01T00:47:51Z an instance was taken out of service in response to a system health-check. Description: Terminating EC2 instance: i-88ce28f1 Auto Scaling maintains the desired number of instances by monitoring the health status of the instances in the Auto Scaling group. When Auto Scaling receives notification that an instance is unhealthy or terminated, Auto Scaling launches another instance to take the place of the unhealthy instance. For information about how Auto Scaling monitors the health status of instances, go to Maintaining Current Scaling Level in the Auto Scaling Developer Guide.
Note
Auto Scaling provides the cause of instance termination that is not the result of a scaling activity. This includes instances that have been terminated because the Spot market price exceeded their bid price. When Auto Scaling attempts to replace terminated instances resulting from the Spot market price rising above the instances' bid price, Auto Scaling will place the bid specified in the current launch configuration and attempt to launch another instance to maintain the desired capacity.
To confirm that Auto Scaling is launching your Spot Instances according to your specifications
Use as-describe-auto-scaling-groups. The command will show details about the group and instances launched. For information about the as-describe-auto-scaling-groups command, see Verify Auto Scaling Group Creation in the Auto Scaling Developer Guide. 1. 2. Open a command line and navigate to the bin folder of your Auto Scaling CLI tools directory. Type the command:as-describe-auto-scaling-groups spotasg --headers
Note
The --headers option supplies the column name so you know what data is being returned. The information you get should be similar to the following example.
AUTO-SCALING-GROUP GROUP-NAME LAUNCH-CONFIG AVAILABILITY-ZONES MIN-SIZE MAX-SIZE DESIRED-CAPACITY AUTO-SCALING-GROUP spotasg spotlc-5cents us-east-1b,us-east-1a 1 5 3 INSTANCE INSTANCE-ID AVAILABILITY-ZONE STATE STATUS LAUNCH-CONFIG INSTANCE i-2c30d155 us-east-1a InService Healthy spotlc-5cents INSTANCE i-fe30d187 us-east-1a InService Healthy spotlc-5cents INSTANCE i-c630d1bf us-east-1a InService Healthy spotlc-5cents
You can see that Auto Scaling launched 3 instances in us-east-1a, as you specified, and they are all running. 3. Additionally, you can find out details about the Spot Instances launched for you by Auto Scaling, by using the as-describe-auto-scaling-instances command. This is the basic syntax:
as-describe-auto-scaling-instances [InstanceIds [InstanceIds ...]] [--max-records value] [General Options]
Specifying InstanceIds is optional. If you specify it, the command will return information about the instance, if it exists. If you don't specify InstanceIds, the command returns information about all instances associated with your Auto Scaling account.
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
In this walkthrough, we are assuming that you created one launch configuration and Auto Scaling group, and you want to find out details about all your Spot Instances. Your command should look like the following example:
as-describe-auto-scaling-instances --headers
What do you want to do next? Updating the Bid Price for the Spot Instances (p. 171) Scheduling Spot Bid Requests (p. 173) Using Auto Scaling to Get Notifications for Spot Instances (p. 174) Advanced Tasks (p. 180)
Note
If you don't have an AMI, and you want to find a suitable one, see Amazon Machine Images (AMIs). Instance type = m1.small Spot price = $0.07 Your command should look similar to the following example:
as-create-launch-config spotlc-7cents --image-id ami-e565ba8c --instance-type m1.small --spot-price "0.07"
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
After you have created the new launch configuration successfully, create a new Auto Scaling group specifying the new launch configuration. Your command should look similar to the following example:
as-create-auto-scaling-group spotasg-7cents --launch-configuration spotlc-7cents --availability-zones "us-east-1a,us-east-1b" --max-size 5 --min-size 10 --de sired-capacity 3
You can view the status of your Spot bid and a list of the bids that Auto Scaling placed for you by running as-describe-scaling-activities soon after you create your Auto Scaling group. Your command should look similar to the following example:
as-describe-scaling-activities --headers
If not all your bids are fulfilled, you will get information that looks like the following example:
ACTIVITY ACTIVITY-ID END-TIME GROUPNAME CODE MESSAGE ACTIVITY 5879cc50-1e40-4539-a754-1cb084f1aecd spotasg7cents WaitingForSpotInstanceId Placed Spot instance request: sir-93828812. Waiting for instance(s) ACTIVITY 777fbe1b-7a24-4aaf-b7a9-d368d0511878 spotasg7cents WaitingForSpotInstanceId Placed Spot instance request: sir-016cf812. Waiting for instance(s) ACTIVITY f4b00f81-eaea-4421-80b4-a2e3a35cc782 spotasg7cents WaitingForSpotInstanceId Placed Spot instance request: sir-cf60ea12. Waiting for instance(s) ACTIVITY 31bcbb67-7f50-4b88-ae7e-e564a8c80a90 spotasg WaitingForSpotInstanceId Placed Spot instance request: sir-fc8a3014. Waiting for instance(s) ACTIVITY 770bbeb5-407c-404c-a826-856f65db1c57 spotasg WaitingForSpotInstanceId Placed Spot instance request: sir-69101014. Waiting for instance(s) ACTIVITY 597e4ebd-220e-42bc-8ac9-2bae4d20b8d7 2012-05-23T17:40:22Z spotasg Successful ACTIVITY eca158b4-a6f9-4ec5-a813-78d42c1738e2 Successful ACTIVITY 1a5bd6c6-0b0a-4917-8cf0-eee1044a179f Successful ACTIVITY c285bf16-d2c4-4ae8-acad-7450655facb5 2012-05-23T17:40:22Z spotasg
2012-05-23T17:22:19Z
spotasg
2012-05-23T17:22:19Z
spotasg
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Successful ACTIVITY 127e3608-5911-4111-906e-31fb16d43f2e Successful ACTIVITY bfb548ad-8bc7-4a78-a7db-3b41f73501fc Successful ACTIVITY 82d2b9bb-3d64-46d9-99b6-054a9ecf5ac2 Successful ACTIVITY 95b7589b-f8ac-49bc-8c83-514bf664b4ee Successful ACTIVITY 57bbf77a-99d6-4d94-a6db-76b2307fb9de Successful ACTIVITY cdef758e-0be2-416e-b402-0ef521861039 Successful ACTIVITY d7e0a3ed-7067-4583-8a87-1561b3de2aed Successful ACTIVITY da5471ab-482c-4680-b430-99e4173d2bd7 Successful ACTIVITY 78701f3d-a747-46e1-8b0f-8aff22834f46 Successful ACTIVITY 274d4772-3614-4f5c-8858-026b33635be3 Successful ACTIVITY 1024abb2-bf84-4fae-b717-a398bac91c4f Successful 2012-05-23T15:38:06Z spotasg
2012-05-23T15:38:07Z
spotasg
2012-05-23T15:30:28Z
spotasg
2012-05-23T15:30:28Z
spotasg
2012-05-23T15:16:34Z
spotasg
2012-05-23T15:16:17Z
spotasg
2012-05-23T14:51:46Z
spotasg
2012-05-23T14:52:48Z
spotasg
2012-05-23T14:38:17Z
spotasg
2012-05-23T14:38:16Z
spotasg
2012-05-23T14:22:39Z
spotasg
Bids are represented by values such as sir-93828812 and sir-016cf812. When you create a new launch configuration that sets a new bid price for Spot Instances, and you have Spot Instances already running based on a different price, these instances will continue running and will only be terminated if the Spot market price goes above the bid price on which it was based. What do you want to do next? Scheduling Spot Bid Requests (p. 173) Using Auto Scaling to Get Notifications for Spot Instances (p. 174) Advanced Tasks (p. 180)
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
as-put-scheduled-update-group-action ScheduledActionName --auto-scaling-group value [--desired-capacity value] [--end-time value][--max-size value][--min-size value] [--recurrence value][--start-time value][--time value][General Options]
In this scenario, use the following values: Scheduled action name: as-spotbid-schedule Auto Scaling group: spotasg Start time: 2012-05-15T19:10:00Z End time: 2012-05-15T19:15:00Z Desired capacity:20 Your command should look similar to the following example:
as-put-scheduled-update-group-action as-spotbid-schedule --auto-scaling-group spotasg --desired-capacity 20 --start-time 2012-05-15T19:10:00Z --end-time 201205-15T19:15:00Z
To check your scheduled action, run as-describe-scheduled-actions. You will get information similar to the following example:
UPDATE-GROUP-ACTION spotasg as-spotbid-schedule 2012-05-15T19:10:00Z 20
What do you want to do next? Obtaining Information About the Instances Launched by Auto Scaling (p. 167) Updating the Bid Price for the Spot Instances (p. 171) Using Auto Scaling to Get Notifications for Spot Instances (p. 174) Advanced Tasks (p. 180)
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
You can also use the AWS Java SDK to develop applications that monitor your Spot Instance usage in ways that are customized to your use case.The Spot Notifications sample application is a Java application that demonstrates techniques for monitoring Amazon EC2 instance status, Spot Instance requests, and Spot Price fluctuations. The application is documented and freely available for download at How to Track Spot Instance Activity with the Spot-Notifications Sample Application.You are free to adapt the application for your own purposes, or use it as a guide in developing your own application for monitoring Spot Instances. For more information, go to the AWS SDK for Java. Configuring Auto Scaling groups to send notifications about your Spot Instances In this portion of the walkthrough, you learn how to set up Amazon SNS to send email notifications. To do this, you need the following: An Amazon Resource Name (ARN). You generate an ARN when you create an Amazon Simple Notification Service (Amazon SNS) topic. A topic is a communication channel to send messages and subscribe to notifications. It provides an access point for publishers and subscribers to communicate with each other. An endpoint, such as an email address, must be subscribed to the topic so the endpoint can receive messages published to the topic. To create a topic, go to Create a Topic in the Amazon Simple Notification Service Getting Started Guide. An Auto Scaling Group. Use the Auto Scaling group that you created earlier in this walkthrough. A notification configuration. You configure an Auto Scaling group to send notifications when specified events take place by calling the as-put-notification-configuration CLI command or the PutNotificationConfiguration API action. We will discuss the steps in setting up a notification configuration later in this section. For more information about the command, go to PutNotificationConfiguration in the Auto Scaling API Reference. A list of Auto Scaling notification types. These notification types are the events that will cause the notification to be sent. Set Up Notifications Using Auto Scaling 1. After you've created your Amazon SNS topic and you have the ARN, you are ready to set up the notification configuration. (To create a topic, go to Create a Topic in the Amazon Simple Notification Service Getting Started Guide.) To configure your Auto Scaling group to send notifications when specified events take place, use the as-put-notification-configuration CLI command. The as-put-notification-configuration command takes the following arguments:
as-put-notification-configuration AutoScalingGroupName --notification-types value --topic-arn topic-ARN [General Options]
You need to specify the Auto Scaling group name, the ARN, and the notification types. For this example, specify: Auto Scaling group name: spotasg Specify the Auto Scaling group that you want to get notifications about. In this walkthrough, you want Auto Scaling to notify you when instances are launched and terminated for the spotasg Auto Scaling group. ARN:arn:placeholder:MyTopic
Note
ARNs are unique identifiers for Amazon Web Services (AWS) resources. Replace the ARN placeholder with your ARN. Notification types: autoscaling:EC2_Instance_Launch, autoscaling:EC2_Instance_Terminate The notification types are the events you want Auto Scaling to send you e-mail about.
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
You now have a notification configuration that sends a notification to the endpoint subscribed in the arn:placeholder:MyTopic ARN whenever instances are launched or terminated. 2. Verify the notification configuration. To verify the notification actions associated with your Auto Scaling group when specified events take place, use as-describe-notification-configurations. The as-describe-notification-configurations command takes the following arguments:
as-describe-notification-configurations [--auto-scaling-groups value[,value...]] [--maxrecords value] [General Options]
If you specify the Auto Scaling group, this command returns a full list of all notification configuration for the Auto Scaling group listed. If you don't provide an Auto Scaling group name, the service returns the full details of all Auto Scaling groups. The command also returns a token if there are more pages to retrieve. To get the next page, call this action again with the returned token as the next-token argument. For this walkthrough, specify: Auto Scaling group name: spotasg Open a command prompt and enter the as-describe-notification-configurations command.
as-describe-notification-configurations --auto-scaling-groups spotasg -headers
You have confirmed that you have a notification configuration set up for the spotasg Auto Scaling group. When Auto Scaling launches instances to reach or maintain desired capacity, as specified in your Auto Scaling group, SNS sends a notification to your email address with information about the instances. You can check your email Inbox for this information, then run as-describe-auto-scaling-group to get information about current instances in the Auto Scaling group and confirm that the instances listed in your email actually exist. What do you want to do next? Obtaining Information About the Instances Launched by Auto Scaling (p. 167) Updating the Bid Price for the Spot Instances (p. 171)
API Version 2013-02-01 176
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Scheduling Spot Bid Requests (p. 173) Advanced Tasks (p. 180)
Note
To launch this template, you need a new SSH private key that you create specifically for this task. You'll have to log in to the instance created by the template and provide this private key information. To download this template, go to Bees with Machine Guns. Grid Computing for Spot Instances This template uses Star Cluster to launch and bootstrap a cluster of Amazon EC2 instances for high performance computational tasks using Spot pricing.You only need to provide the number of instances, instance size, and Spot price that you want to use. To download this template, go to Grid Computing for Spot Instances. You can create stacks from these templates by using the AWS Management Console, the AWS CloudFormation command line tools, or the AWS CloudFormation API. Before you use these templates, you must: 1. Have an AWS account and sign up for AWS CloudFormation. 2. Decide on the template to use. 3. Enter the parameters required for the stack. 4. Create the stack.
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
To get started with AWS CloudFormation, Getting Started with AWS CloudFormation. For more information about using AWS CloudFormation, see the AWS CloudFormation User Guide.
Quick Look: Using Spot Instances with Amazon Elastic MapReduce Video
The following video describes how Spot Instances work in Amazon EMR and walks you through the process of launching a job flow on Spot Instances from the AWS Management Console: Using Spot Instances with Amazon ElasticMapReduce
Note
Support for default VPC is available in select regions, and will be available in all regions soon. For more information, see Default VPC Basics. If your AWS account does not support a default VPC, create an Amazon VPC and specify the subnet of the VPC that you just created. This topic discusses what you need to know if you want your Spot Instances to launch in an Amazon VPC and your account does not support default VPCs, or your account supports default VPCs but you want your Spot Instances to launch in a VPC that is not the default. For more information about setting up an Amazon VPC, see Getting Started with Amazon VPC in the Amazon Virtual Private Cloud Getting Started Guide.
Amazon Elastic Compute Cloud User Guide Walkthroughs: Using Spot Instances with AWS Services
Using the AWS Management Console, check the Spot Price History page to see the Spot pricing history for Amazon EC2 instances running in both Amazon EC2 and Amazon VPC.
Specify the VPC subnet in which you want to launch your Spot Instance. When you use the RequestSpotInstances action or the ec2-request-spot-instances command, specify the ID of the Amazon VPC subnet in which you want to launch the Spot Instance.
PROMPT> ec2-request-spot-instances ami-8e1fece7 -t m1.xlarge -p '$0.01' -n 5 -r 'one-time' -s 'subnet-baab943d3'
When you launch the Request Instances Wizard from the Spot Instance page of the AWS Management Console, select a subnet after specifying that you're launching the Spot Instance into a VPC.
Note
The Request Spot Instances page shows the VPC option only if you have created a VPC and subnet before making the Spot Instance request. For more information about using Amazon VPC, see the Amazon Virtual Private Cloud User Guide.
Advanced Tasks
Now that you have created Spot Instance requests and worked with Spot Instances, this section discusses some advanced tasks. Subscribe to Your Spot Instance Data Feed (p. 180) Programming Spot with AWS Java SDK (p. 183) Starting Clusters on Spot Instances (p. 210) If you think we should add other advanced tasks to this section, let us know at spot-instance-feedback@amazon.com.
For example, if your bucket name is myawsbucket, and you name your prefix myprefix, your filenames look similar to this:
myawsbucket.s3.amazonaws.com/myprefix/111122223333.2010-03-17-20.001.pwBdGTJG.gz
Data feed files arrive in your bucket typically once an hour and each hour of usage is typically covered in a single data file. These files are compressed (gzip) before delivery into your bucket. We can write multiple files for a given hour of usage where files are very large (for example, when file contents for the hour exceed 50 MB before compression).
Note
If you don't have a Spot Instance running during a certain hour, you won't receive a data feed file for that hour. The Spot Instance data feed files are tab-delimited. Each line in the data file corresponds to one instance-hour. Each line contains the fields listed in the following table. Field
Timestamp UsageType
Description The timestamp used to determine the price charged for this instance-hour. Indicates the type of usage and instance type being charged for. For m1.small Spot Instances, this field is set to "SpotUsage." For all other instance types, this field is set to "SpotUsage:{instance-type}," for example, SpotUsage:c1.medium. Indicates the product being charged for. For Linux/UNIX Spot Instances, this field is set to RunInstances. For Microsoft Windows, this field is set to "RunInstances:0002." Spot usage is grouped according to Availability Zone. The instance ID for the Spot Instance that generated this instance-hour. The Spot Instance request ID for the request that generated this instance-hour. The maximum price specified for this Spot Instance request. The Spot Price at the time specified in the Timestamp field. The price charged for this instance-hour. The version included in the data feed filename for this record.
Operation
When you create your data feed subscription, Amazon EC2 updates the designated bucket's ACL to allow read and write permissions for the AWS data feeds account. Each data feed file has its own ACL (separate from the bucket's ACL). The bucket owner has FULL_CONTROL permission for the data files. The data feed account has read and write permission. Removing the permissions for the data feed account does not disable the data feed. If you remove those permissions but don't disable the data feed (which you do with the control API), we reinstate those permissions the next time the data feeds account needs to write a data file to your bucket. If you delete your data feed subscription, Amazon EC2 doesn't remove the read/write permissions for the data feed account on either the bucket or the data files. You must perform remove the read/write permissions yourself.
Prerequisites
To use this tutorial you need to be signed up for Amazon Web Services (AWS). If you have not yet signed up for AWS, go to the Amazon Web Services website, and click Create an AWS Account in the upper right corner of the page. In addition, you also need to install the AWS Java SDK. If you are using the Eclipse development environment, we recommend that you install the AWS Toolkit for Eclipse. Note that the AWS Toolkit for Eclipse includes the latest version of the AWS SDK for Java.
Copy and paste your Access Key and Secret Access Key into the AwsCredentials.properties file. To learn more about setting up security credentials go to Amazon EC2 Security Credentials. Now that you have configured your settings, you can get started using the code in the the example.
GroupRequest("GettingStartedGroup", "Getting Started Security Group"); ec2.createSecurityGroup(securityGroupRequest); 20 } catch (AmazonServiceException ase) { // Likely this means that the group is already created, so ignore. System.out.println(ase.getMessage()); } 25 String ipAddr = "0.0.0.0/0"; // Get the IP of the current host, so that we can limit the Security // Group by default to the ip range associated with your subnet. try { 30 InetAddress addr = InetAddress.getLocalHost(); // Get IP Address ipAddr = addr.getHostAddress()+"/10"; } catch (UnknownHostException e) { 35 } // Create a range that you would like to populate. ArrayList<String> ipRanges = new ArrayList<String>(); ipRanges.add(ipAddr); 40 // Open up port 22 for TCP traffic to the associated IP // from above (e.g. ssh traffic). ArrayList<IpPermission> ipPermissions = new ArrayList<IpPermission> (); IpPermission ipPermission = new IpPermission(); 45 ipPermission.setIpProtocol("tcp"); ipPermission.setFromPort(new Integer(22)); ipPermission.setToPort(new Integer(22)); ipPermission.setIpRanges(ipRanges); ipPermissions.add(ipPermission); 50 try { // Authorize the ports to the used. AuthorizeSecurityGroupIngressRequest ingressRequest = new AuthorizeSecurityGroupIngressRequest("GettingStartedGroup",ip Permissions); 55 ec2.authorizeSecurityGroupIngress(ingressRequest); } catch (AmazonServiceException ase) { // Ignore because this likely means the zone has // already been authorized. System.out.println(ase.getMessage()); 60 }
You can view this entire code sample in the CreateSecurityGroupApp.java code sample. Note you only need to run this application once to create a new security group. You can also create the security group using the AWS Toolkit for Eclipse. Go to the toolkit documentation for more information.
There are several instance types to choose from; go to Amazon EC2 Instance Types for a complete list. For this tutorial, we will use t1.micro, the cheapest instance type available. Next, we will determine the type of AMI we would like to use. We'll use ami-8c1fece5, the most up-to-date Amazon Linux AMI available when we wrote this tutorial. The latest AMI may change over time, but you can always determine the latest version AMI by: 1. Logging into the AWS Management Console, clicking the EC2 tab, and, from the EC2 Console Dashboard, attempting to launch an instance.
2.
In the window that displays AMIs, just use the AMI ID as shown in the following screen shot. Alternatively, you can use the DescribeImages API, but leveraging that command is outside the scope of this tutorial.
There are many ways to approach bidding for Spot instances; to get a broad overview of the various approaches you should view the Bidding for Spot Instances video. However, to get started, we'll describe three common strategies: bid to ensure cost is less than on-demand pricing; bid based on the value of the resulting computation; bid so as to acquire computing capacity as quickly as possible. Reduce Cost below On-Demand You have a batch processing job that will take a number of hours or days to run. However, you are flexible with respect to when it starts and when it completes. You want to see if you can complete it for less cost than with On-Demand Instances. You examine the Spot Price history for instance types using either the AWS Management Console or the Amazon EC2 API. For more information, go to Viewing Spot Price History. After you've analyzed the price history for your desired instance type in a given Availability Zone, you have two alternative approaches for your bid: You could bid at the upper end of the range of Spot Prices (which are still below the On-Demand price), anticipating that your one-time Spot request would most likely be fulfilled and run for enough consecutive compute time to complete the job. Or, you could bid at the lower end of the price range, and plan to combine many instances launched over time through a persistent request. The instances would run long enough--in aggregate--to complete the job at an even lower total cost. (We will explain how to automate this task later in this tutorial.) Pay No More than the Value of the Result You have a data processing job to run. You understand the value of the job's results well enough to know how much they are worth in terms of computing costs. After you've analyzed the Spot Price history for your instance type, you choose a bid price at which the cost of the computing time is no more than the value of the job's results. You create a persistent bid and allow it to run intermittently as the Spot Price fluctuates at or below your bid. Acquire Computing Capacity Quickly You have an unanticipated, short-term need for additional capacity that is not available through On-Demand Instances. After you've analyzed the Spot Price
history for your instance type, you bid above the highest historical price to provide a high likelihood that your request will be fulfilled quickly and continue computing until it completes.
After you choose your bid price, you are ready to request a Spot Instance. For the purposes of this tutorial, we will bid the On-Demand price ($0.03) to maximize the chances that the bid will be fulfilled. You can determine the types of available instances and the On-Demand prices for instances by going to Amazon EC2 Pricing page. To request a Spot Instance, you simply need to build your request with the parameters you chose earlier. We start by creating a RequestSpotInstanceRequest object. The request object requires the number of instances you want to start and the bid price. Additionally, you need to set the LaunchSpecification for the request, which includes the instance type, AMI ID, and security group you want to use. Once the request is populated, you call the requestSpotInstances method on the AmazonEC2Client object. The following example shows how to request a Spot Instance.
1 // Retrieves the credentials from a AWSCrentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Setup the specifications of the launch. This includes the // instance type (e.g. t1.micro) and the latest Amazon Linux 25 // AMI id available. Note, you should always use the latest // Amazon Linux AMI id or another of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); 30 // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); 35 // Add the launch specifications to the request. requestRequest.setLaunchSpecification(launchSpecification); // Call the RequestSpotInstance API. 40 RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re
questRequest);
Running this code will launch a new Spot Instance Request. There are other options you can use to configure your Spot Requests. To learn more, please visit the Java Developers: Advanced Spot Features Tutorials or the RequestSpotInstances API in the Java SDK.
Note
You will be charged for any Spot Instances that are actually launched, so make sure that you cancel any requests and terminate any instances you launch to reduce any associated fees.
To monitor your request ID, call the describeSpotInstanceRequests method to determine the state of the request. Then loop until the request is not in the "open" state. Note that we monitor for a state of not "open", rather a state of, say, "active", because the request can go straight to "closed" if there is a problem with your request arguments. The following code example provides the details of how to accomplish this task.
1 // Create a variable that will track whether there are any // requests still in the open state. boolean anyOpen; 5 do { // Create the describeRequest object with all of the request ids // to monitor (e.g. that we started).
DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpot InstanceRequestsRequest(); 10 describeRequest.setSpotInstanceRequestIds(spotInstanceRequestIds); // Initialize the anyOpen variable to false - which assumes there // are no requests open unless we find one that is still open. anyOpen=false; 15 try { // Retrieve all of the requests we want to monitor. DescribeSpotInstanceRequestsResult describeResult = ec2.describeS potInstanceRequests(describeRequest); List<SpotInstanceRequest> describeResponses = describeResult.get SpotInstanceRequests(); 20 // Look through each request and determine if they are all in // the active state. for (SpotInstanceRequest describeResponse : describeResponses) { // If the state is open, it hasn't changed since we attempted 25 // to request it. There is the potential for it to transition // almost immediately to closed or canceled so we compare // against open instead of active. if (describeResponse.getState().equals("open")) { anyOpen = true; 30 break; } } } catch (AmazonServiceException e) { // If we have an exception, ensure we don't break out of 35 // the loop. This prevents the scenario where there was // blip on the wire. anyOpen = true; } 40 try { // Sleep for 60 seconds. Thread.sleep(60*1000); } catch (Exception e) { // Do nothing because it woke up early. 45 } } while (anyOpen);
After running this code, your Spot Instance Request will have completed or will have failed with an error that will be output to the screen. In either case, we can proceed to the next step to clean up any active requests and terminate any running instances.
1 try { // Cancel requests. CancelSpotInstanceRequestsRequest cancelRequest = new CancelSpotInstan ceRequestsRequest(spotInstanceRequestIds); 5 ec2.cancelSpotInstanceRequests(cancelRequest); } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error canceling instances"); System.out.println("Caught Exception: " + e.getMessage()); 10 System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.getRequestId()); }
To terminate any outstanding instances, you will need the instance ID associated with the request that started them. The following code example takes our original code for monitoring the instances and adds an ArrayList in which we store the instance ID associated with the describeInstance response.
1 // Create a variable that will track whether there are any requests // still in the open state. boolean anyOpen; 5 // Initialize variables. ArrayList<String> instanceIds = new ArrayList<String>(); do { // Create the describeRequest with all of the request ids to // monitor (e.g. that we started). DescribeSpotInstanceRequestsRequest describeRequest = new DescribeSpot InstanceRequestsRequest(); describeRequest.setSpotInstanceRequestIds(spotInstanceRequestIds); 15 // Initialize the anyOpen variable to false, which assumes there // are no requests open unless we find one that is still open. anyOpen = false; 10
try { // Retrieve all of the requests we want to monitor. DescribeSpotInstanceRequestsResult describeResult = ec2.describeS potInstanceRequests(describeRequest); List<SpotInstanceRequest> describeResponses = describeResult.get SpotInstanceRequests(); 20 // Look through each request and determine if they are all // in the active state. for (SpotInstanceRequest describeResponse : describeResponses) { // If the state is open, it hasn't changed since we // attempted to request it. There is the potential for // it to transition almost immediately to closed or // canceled so we compare against open instead of active. if (describeResponse.getState().equals("open")) { anyOpen = true; break; }
25
30
35 // Add the instance id to the list we will // eventually terminate. instanceIds.add(describeResponse.getInstanceId()); } } catch (AmazonServiceException e) { // If we have an exception, ensure we don't break out // of the loop. This prevents the scenario where there // was blip on the wire. anyOpen = true; }
40
45
try { // Sleep for 60 seconds. Thread.sleep(60*1000); 50 } catch (Exception e) { // Do nothing because it woke up early. } } while (anyOpen);
Using the instance IDs, stored in the ArrayList, terminate any running instances using the following code snippet.
1 try { // Terminate instances. TerminateInstancesRequest terminateRequest = new TerminateInstances Request(instanceIds); 5 ec2.terminateInstances(terminateRequest); } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error terminating instances"); System.out.println("Caught Exception: " + e.getMessage()); 10 System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.getRequestId()); }
Next Steps
We recommend that you take the Java Developers: Tutorial: Advanced Amazon EC2 Spot Request Management (p. 194).
Prerequisites
To use this tutorial you need to be signed up for Amazon Web Services (AWS). If you have not yet signed up for AWS, go to the Amazon Web Services website, and click Create an AWS Account in the upper right corner of the page. In addition, you also need to install the AWS Java SDK. If you are using the Eclipse development environment, we recommend that you install the AWS Toolkit for Eclipse. Note that the AWS Toolkit for Eclipse includes the latest version of the AWS SDK for Java.
Copy and paste your Access Key and Secret Access Key into the AwsCredentials.properties file. To learn more about setting up security credentials go to Amazon EC2 Security Credentials.
traffic from the IP address where you are running your application from. To set up a new security group, you need to include or run the following code sample that sets up the security group programmatically. After we create an AmazonEC2 client object, we create a CreateSecurityGroupRequest object with the name, "GettingStarted" and a description for the security group. Then we call the ec2.createSecurityGroup API to create the group. To enable access to the group, we create an ipPermission object with the IP address range set to the CIDR representation of the subnet for the local computer; the "/10" suffix on the IP address indicates the subnet for the specified IP address. We also configure the ipPermission object with the TCP protocol and port 22 (SSH). The final step is to call ec2.authorizeSecurityGroupIngress with the name of our security group and the ipPermission object. (The following code is the same as what we used in the first tutorial.)
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCreden tials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Create a new security group. try { CreateSecurityGroupRequest securityGroupRequest = new CreateSecurityGroupRequest("GettingStartedGroup", "Getting Started Security Group"); 20 ec2.createSecurityGroup(securityGroupRequest); } catch (AmazonServiceException ase) { // Likely this means that the group is already created, so ignore. System.out.println(ase.getMessage()); } 25 String ipAddr = "0.0.0.0/0"; // Get the IP of the current host, so that we can limit the Security Group // by default to the ip range associated with your subnet. 30 try { InetAddress addr = InetAddress.getLocalHost(); // Get IP Address ipAddr = addr.getHostAddress()+"/10"; 35 } catch (UnknownHostException e) { } // Create a range that you would like to populate. ArrayList<String> ipRanges = new ArrayList<String>(); 40 ipRanges.add(ipAddr);
// Open up port 22 for TCP traffic to the associated IP from // above (e.g. ssh traffic). ArrayList<IpPermission> ipPermissions = new ArrayList<IpPermission> (); 45 IpPermission ipPermission = new IpPermission(); ipPermission.setIpProtocol("tcp"); ipPermission.setFromPort(new Integer(22)); ipPermission.setToPort(new Integer(22)); ipPermission.setIpRanges(ipRanges); 50 ipPermissions.add(ipPermission); try { // Authorize the ports to the used. AuthorizeSecurityGroupIngressRequest ingressRequest = 55 new AuthorizeSecurityGroupIngressRequest("GettingStartedGroup",ip Permissions); ec2.authorizeSecurityGroupIngress(ingressRequest); } catch (AmazonServiceException ase) { // Ignore because this likely means the zone has already // been authorized. 60 System.out.println(ase.getMessage()); }
You can view this entire code sample in the advanced.CreateSecurityGroupApp.java code sample. Note you only need to run this application once to create a new security group. You can also create the security group using the AWS Toolkit for Eclipse. Go to the toolkit documentation for more information.
// Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set up the specifications of the launch. This includes the // instance type (e.g. t1.micro) and the latest Amazon Linux 25 // AMI id available. Note, you should always use the latest // Amazon Linux AMI id or another of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); 30 // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); 35 // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); // Call the RequestSpotInstance API. 40 RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
15 AmazonEC2 ec2 = new AmazonEC2Client(credentials); // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); 20 // Request 1 x t1.micro instance with a bid price of $0.03. requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set the type of the bid to persistent. 25 requestRequest.setType("persistent"); // Set up the specifications of the launch. This includes the // instance type (e.g. t1.micro) and the latest Amazon Linux // AMI id available. Note, you should always use the latest 30 // Amazon Linux AMI id or another of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); 35 // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); 40 // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest); 45
15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set the valid start time to be two minutes from now. Calendar cal = Calendar.getInstance(); 25 cal.add(Calendar.MINUTE, 2); requestRequest.setValidFrom(cal.getTime()); // Set the valid end time to be two minutes and two hours from now. cal.add(Calendar.HOUR, 2); 30 requestRequest.setValidUntil(cal.getTime()); // Set up the specifications of the launch. This includes // the instance type (e.g. t1.micro) 35 // and the latest Amazon Linux AMI id available. // Note, you should always use the latest Amazon // Linux AMI id or another of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); 40 launchSpecification.setInstanceType("t1.micro"); // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); 45 launchSpecification.setSecurityGroups(securityGroups); // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); 50 // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 5 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(5)); // Set the launch group. requestRequest.setLaunchGroup("ADVANCED-DEMO-LAUNCH-GROUP"); 25 // Set up the specifications of the launch. This includes // the instance type (e.g. t1.micro) and the latest Amazon Linux // AMI id available. Note, you should always use the latest // Amazon Linux AMI id or another of your choosing. 30 LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); // Add the security group to the request. 35 ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); // Add the launch specification. 40 requestRequest.setLaunchSpecification(launchSpecification); // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
If you want to ensure that all instances within a request are launched in the same Availability Zone, and you don't care which one, you can leverage Availability Zone groups. An Availability Zone group is a label that groups a set of instances together in the same Availability Zone. All instances that share an Availability Zone group and are fulfilled at the same time will start in the same Availability Zone. An example of how to set an Availability Zone group follows.
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties"));
} catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 5 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(5)); // Set the availability zone group. requestRequest.setAvailabilityZoneGroup("ADVANCED-DEMO-AZ-GROUP"); 25 // Set up the specifications of the launch. This includes the instance // type (e.g. t1.micro) and the latest Amazon Linux AMI id available. // Note, you should always use the latest Amazon Linux AMI id or another // of your choosing. 30 LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); // Add the security group to the request. 35 ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); // Add the launch specification. 40 requestRequest.setLaunchSpecification(launchSpecification); // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
You can specify an Availability Zone that you want for your Spot Instances. The following code example shows you how to set an Availability Zone.
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1);
} // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set up the specifications of the launch. This includes the instance // type (e.g. t1.micro) and the latest Amazon Linux AMI id available. 25 // Note, you should always use the latest Amazon Linux AMI id or another // of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); 30 // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); 35 // Set up the availability zone to use. Note we could retrieve the // availability zones using the ec2.describeAvailabilityZones() API. For // this demo we will just use us-east-1a. SpotPlacement placement = new SpotPlacement("us-east-1b"); 40 launchSpecification.setPlacement(placement); // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); 45 // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
Lastly, you can specify a placement group if you are using High Performance Computing (HPC) Spot instances, such as cluster compute instances or cluster GPU instances. Placement groups provide you with lower latency and high-bandwidth connectivity between the instances. An example of how to set a placement group follows.
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage());
10 }
System.exit(-1);
// Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set up the specifications of the launch. This includes the instance // type (e.g. t1.micro) and the latest Amazon Linux AMI id available. 25 // Note, you should always use the latest Amazon Linux AMI id or another // of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); 30 // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); 35 // Set up the placement group to use with whatever name you desire. // For this demo we will just use "ADVANCED-DEMO-PLACEMENT-GROUP". SpotPlacement placement = new SpotPlacement(); placement.setGroupName("ADVANCED-DEMO-PLACEMENT-GROUP"); 40 launchSpecification.setPlacement(placement); // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); 45 // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
All of the parameters shown in this section are optional. It is also important to realize that most of these parameterswith the exception of whether your bid is one-time or persistentcan reduce the likelihood of bid fulfillment. So, it is important to leverage these options only if you need them. All of the preceding code examples are combined into one long code sample, which can be found in the com.amazonaws.codesamples.advanced.InlineGettingStartedCodeSampleApp.java class.
In the added code, we create a BlockDeviceMapping object and set its associated Elastic Block Storage (EBS) to an EBS object that we've configured to not be deleted if the Spot Instance is terminated. We then add this BlockDeviceMapping to the ArrayList of mappings that we include in the launch specification.
1 // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { 5 credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper ties")); } catch (IOException e1) { System.out.println("Credentials were not properly entered into AwsCre dentials.properties."); System.out.println(e1.getMessage()); 10 System.exit(-1); } // Create the AmazonEC2Client object so we can call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials); 15 // Initializes a Spot Instance Request RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. 20 requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); // Set up the specifications of the launch. This includes the instance // type (e.g. t1.micro) and the latest Amazon Linux AMI id available. 25 // Note, you should always use the latest Amazon Linux AMI id or another // of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); 30 // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); 35 // Create the block device mapping to describe the root partition. BlockDeviceMapping blockDeviceMapping = new BlockDeviceMapping(); blockDeviceMapping.setDeviceName("/dev/sda1"); 40 // Set the delete on termination flag to false. EbsBlockDevice ebs = new EbsBlockDevice(); ebs.setDeleteOnTermination(Boolean.FALSE); blockDeviceMapping.setEbs(ebs); 45 // Add the block device mapping to the block list. ArrayList<BlockDeviceMapping> blockList = new ArrayList<BlockDeviceMap ping>(); blockList.add(blockDeviceMapping); // Set the block device mapping configuration in the launch specifications.
50 launchSpecification.setBlockDeviceMappings(blockList); // Add the launch specification. requestRequest.setLaunchSpecification(launchSpecification); 55 // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest);
Assuming you wanted to re-attach this volume to your instance on startup, you can also use the block device mapping settings. Alternatively, if you attached a non-root partition, you can specify the Amazon EBS volumes you want to attach to your Spot instance after it resumes. You do this simply by specifying a snapshot ID in your EbsBlockDevice and alternative device name in your BlockDeviceMapping objects. By leveraging block device mappings, it can be easier to bootstrap your instance. Using the root partition to checkpoint your critical data is a great way to manage the potential for interruption of your instances. For more methods on managing the potential of interruption, please visit the Managing Interruption video.
import com.amazonaws.services.ec2.AmazonEC2Client; import com.amazonaws.services.ec2.model.CancelSpotInstanceRequestsRequest; import com.amazonaws.services.ec2.model.CreateTagsRequest; 30 import com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsRequest; import com.amazonaws.services.ec2.model.DescribeSpotInstanceRequestsResult; import com.amazonaws.services.ec2.model.LaunchSpecification; import com.amazonaws.services.ec2.model.RequestSpotInstancesRequest; import com.amazonaws.services.ec2.model.RequestSpotInstancesResult; 35 import com.amazonaws.services.ec2.model.SpotInstanceRequest; import com.amazonaws.services.ec2.model.Tag; import com.amazonaws.services.ec2.model.TerminateInstancesRequest; /** * Welcome to your new AWS Java SDK based project! * * This class is meant as a starting point for your console-based application that * makes one or more calls to the AWS services supported by the Java SDK, such as EC2, * SimpleDB, and S3. 45 * * In order to use the services in this sample, you need: * * - A valid Amazon Web Services account. You can register for AWS at: * https://aws-portal.amazon.com/gp/aws/developer/registration/in dex.html 50 * * - Your account's Access Key ID and Secret Access Key: * http://aws.amazon.com/security-credentials * * - A subscription to Amazon EC2. You can sign up for EC2 at: 55 * http://aws.amazon.com/ec2/ * */ 40 public class InlineTaggingCodeSampleApp { 60 /** * @param args */ public static void main(String[] args) { //==============================================================// //================ Submitting a Request ========================// //==============================================================// // Retrieves the credentials from an AWSCredentials.properties file. AWSCredentials credentials = null; try { credentials = new PropertiesCredentials( GettingStartedApp.class.getResourceAsStream("AwsCredentials.proper
65
70
ties")); } catch (IOException e1) { 75 System.out.println("Credentials were not properly entered into AwsCredentials.properties."); System.out.println(e1.getMessage()); System.exit(-1); }
80
// Create the AmazonEC2Client object so we can // call various APIs. AmazonEC2 ec2 = new AmazonEC2Client(credentials);
// Initializes a Spot Instance Request 85 RequestSpotInstancesRequest requestRequest = new RequestSpotInstances Request(); // Request 1 x t1.micro instance with a bid price of $0.03. requestRequest.setSpotPrice("0.03"); requestRequest.setInstanceCount(Integer.valueOf(1)); 90 // Set up the specifications of the launch. This includes // the instance type (e.g. t1.micro) and the latest Amazon // Linux AMI id available. Note, you should always use the // latest Amazon Linux AMI id or another of your choosing. LaunchSpecification launchSpecification = new LaunchSpecification(); launchSpecification.setImageId("ami-8c1fece5"); launchSpecification.setInstanceType("t1.micro"); // Add the security group to the request. ArrayList<String> securityGroups = new ArrayList<String>(); securityGroups.add("GettingStartedGroup"); launchSpecification.setSecurityGroups(securityGroups); // Add the launch specifications to the request. requestRequest.setLaunchSpecification(launchSpecification); //============================================================// //======== Getting the Request ID from the Request ===========// //============================================================// 110 // Call the RequestSpotInstance API. RequestSpotInstancesResult requestResult = ec2.requestSpotInstances(re questRequest); List<SpotInstanceRequest> requestResponses = requestResult.getSpotIn stanceRequests(); 115 // Set up an arraylist to collect all of the request ids we want to // watch hit the running state. ArrayList<String> spotInstanceRequestIds = new ArrayList<String>();
95
100
105
// Add all of the request ids to the hashset, so we can // determine when they hit the active state. for (SpotInstanceRequest requestResponse : requestResponses) { System.out.println("Created Spot Request: "+requestResponse.getSpot InstanceRequestId()); spotInstanceRequestIds.add(requestResponse.getSpotInstanceRequestId()); } 125 //==========================================================// //============= Tag the Spot Requests ======================// //==========================================================// 120 130 // Create the list of tags we want to create ArrayList<Tag> requestTags = new ArrayList<Tag>(); requestTags.add(new Tag("keyname1","value1"));
135
// Create a tag request for the requests. CreateTagsRequest createTagsRequest_requests = new CreateTagsRequest(); createTagsRequest_requests.setResources(spotInstanceRequestIds); createTagsRequest_requests.setTags(requestTags); // Try to tag the Spot request submitted. try { ec2.createTags(createTagsRequest_requests); } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error terminating instances"); System.out.println("Caught Exception: " + e.getMessage()); System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.getRequestId()); } //===========================================================// //======= Determining the State of the Spot Request =========// //===========================================================//
140
145
150
155
// Create a variable that will track whether there are any // requests still in the open state. boolean anyOpen; // Initialize variables. ArrayList<String> instanceIds = new ArrayList<String>();
160
do { // Create the describeRequest with tall of the request // id to monitor (e.g. that we started). 165 DescribeSpotInstanceRequestsRequest describeRequest = new DescribeS potInstanceRequestsRequest(); describeRequest.setSpotInstanceRequestIds(spotInstanceRequestIds); // Initialize the anyOpen variable to false - which assumes there are no requests open unless // we find one that is still open. 170 anyOpen = false; try { // Retrieve all of the requests we want to monitor. DescribeSpotInstanceRequestsResult describeResult = ec2.describeS potInstanceRequests(describeRequest); 175 List<SpotInstanceRequest> describeResponses = describeResult.get SpotInstanceRequests(); // Look through each request and determine if they are all // in the active state. for (SpotInstanceRequest describeResponse : describeResponses) { // If the state is open, it hasn't changed since we // attempted to request it. There is the potential // for it to transition almost immediately to closed or // canceled so we compare against open instead of active. if (describeResponse.getState().equals("open")) { anyOpen = true; break; }
180
185
190
// Add the instance id to the list we will // eventually terminate. instanceIds.add(describeResponse.getInstanceId()); } } catch (AmazonServiceException e) { // If we have an exception, ensure we don't break out // of the loop. This prevents the scenario where there // was blip on the wire. anyOpen = true; } try { // Sleep for 60 seconds. Thread.sleep(60*1000); } catch (Exception e) { // Do nothing because it woke up early. } } while (anyOpen); //========================================================// //============= Tag the Spot Instances ====================// //========================================================// // Create the list of tags we want to create ArrayList<Tag> instanceTags = new ArrayList<Tag>(); instanceTags.add(new Tag("keyname1","value1"));
195
200
205
210
215 // Create a tag request for instances. CreateTagsRequest createTagsRequest_instances = new CreateTagsRequest(); createTagsRequest_instances.setResources(instanceIds); createTagsRequest_instances.setTags(instanceTags); 220 // Try to tag the Spot instance started. try { ec2.createTags(createTagsRequest_instances); } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error terminating instances"); System.out.println("Caught Exception: " + e.getMessage()); System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.getRequestId()); } //===========================================================// //================== Canceling the Request ==================// //===========================================================//
225
230
235
try { // Cancel requests. CancelSpotInstanceRequestsRequest cancelRequest = new CancelSpotIn stanceRequestsRequest(spotInstanceRequestIds); 240 ec2.cancelSpotInstanceRequests(cancelRequest); } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error canceling instances"); System.out.println("Caught Exception: " + e.getMessage());
245
System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.getRequestId()); }
250
//===========================================================// //=============== Terminating any Instances =================// //===========================================================// try { // Terminate instances. 255 TerminateInstancesRequest terminateRequest = new TerminateInstances Request(instanceIds); ec2.terminateInstances(terminateRequest); } catch (AmazonServiceException e) { // Write out any exceptions that may have occurred. System.out.println("Error terminating instances"); 260 System.out.println("Caught Exception: " + e.getMessage()); System.out.println("Reponse Status Code: " + e.getStatusCode()); System.out.println("Error Code: " + e.getErrorCode()); System.out.println("Request ID: " + e.getRequestId()); } 265 } // main }
Tags are a simple first step toward making it easier to manage your own cluster of instances. To read more about tagging Amazon EC2 resources, go to Using Tags in the Amazon Elastic Compute Cloud User Guide.
you have to process the workload again, it doesnt cost you additional money (you dont pay for the hour if we interrupt your instance). Many customers use a Grid scheduler, such as Oracle Grid Engine or UniCloud, to set up a cluster. If you have long-running workloads, the best practice is to run the master node on On-Demand or Reserved Instances, and run the worker nodes on Spot or a mixture of On-Demand, Reserved, and Spot Instances. Alternatively, if you have a workload that is less than an hour or you are running a test environment, you may want to run all of your instances on Spot. No matter the setup, we recommend that you create a script to automatically re-add instances that may be interrupted. Some existing toolsStarCluster, for example can help you manage this process.
Reserved Instances
You can use Amazon Elastic Compute Cloud (Amazon EC2) Reserved Instances to take advantage of cloud computing while lowering costs and reserving capacity. With Reserved Instances, you pay a low, one-time fee to reserve capacity for a specific instance and get a significant discount on the hourly fee for that instance when you use it. Reserved Instances, which are essentially reserved capacity, can provide substantial savings over owning your own hardware or running only On-Demand instances. When you use Reserved Instances, you know that the capacity you need is available to you when you require it. Launching your Reserved Instance is the same as launching any On-Demand instance: You launch an instance with the same configuration as the capacity you reserved, and AWS will automatically apply the discounted hourly rate that is associated with your capacity reservation. You can use the instance and be charged the discounted rate for as long as you own the Reserved Instance. When the term of your Reserved Instance ends, you can continue using the instance without interruption. Only this time, because you no longer have the capacity reservation, AWS will start charging you the On-Demand rate for usage. Amazon EC2 Reserved Instances are available from AWS in one- and three-year terms. Reserved Instances are also available from third-party sellers through the Reserved Instance Marketplace for periods less than the standard term. The Reserved Instance Marketplace matches sellers who have reserved capacity that they no longer need with buyers who are looking to purchase additional capacity. Reserved Instances bought and sold through the Reserved Instance Marketplace work like any other Reserved Instances. For more information, see Reserved Instance Marketplace (p. 234).
Note
If you are using the Amazon Web Services (AWS) free usage tier to run Amazon EC2 instances, and then you purchase a Reserved Instance, you will be charged for the Reserved Instance under standard pricing guidelines. The AWS free usage tier is available for new AWS accounts. The free tier applies to certain participating AWS services up to a specific maximum amount of usage each month, for a period of a year. When an account goes over the usage limit for a free tier, the standard AWS service rates will be billed to your credit card. For information about the free tier and the applicable services and usage amounts, see AWS Free Usage Tier. Reserved Instances are available in three varietiesHeavy Utilization, Medium Utilization, and Light Utilizationthat enable you to optimize your Amazon EC2 costs based on your expected utilization. You can start lowering your costs today by matching your application's usage pattern with the pricing model that works best for you. To purchase an Amazon EC2 Reserved Instance, you must select an instance type (such as m1.small), platform (Linux/UNIX, Windows, Windows with SQL Server), location (Region and Availability Zone), and term (either one year or three years). When you want your Reserved Instance to run on a specific Linux/UNIX platform, you must identify the specific platform when you purchase the reserved capacity. Then, when you launch your instance with the intention of using the reserved capacity you purchased, you must choose the Amazon Machine Image (AMI) that runs that specific Linux/UNIX platform, along with any other specifications you identified during the purchase. If you want to use Amazon Virtual Private Cloud (Amazon VPC), you must either have an account that supports a default VPC or you must purchase an Amazon VPC Reserved Instance.
Note
If your account supports a default VPC, the list of platforms available does not include Amazon VPC because all platforms have default subnets. If your account supports a default VPC and you launch an instance with the same configuration as the capacity you reserved and paid for, that instance is launched in your default VPC and the capacity guarantees and billing benefits are applied to your instance. If your account does not support a default VPC, you must purchase an Amazon VPC Reserved Instance by selecting a platform that includes Amazon
VPC in its name. For more information, see Detecting Your Supported Platforms and Whether You Have a Default VPC. These sections describe Reserved Instance basics: Reserved Instances Offerings (p. 213) Checklist for Finding, Purchasing, Verifying, and Running Reserved Instances (p. 214)
To understand consolidated billing and how the pricing benefit of Reserved Instances is applied, see Understanding the Pricing Benefit and Consolidated Billing (p. 217). To understand Reserved Instance Pricing Tiers and how to take advantage of the discount pricing, see Understanding Reserved Instance Pricing Tiers (p. 220). If you want to get started with Reserved Instances, see Working with Reserved Instances (p. 228).
Amazon Elastic Compute Cloud User Guide Checklist for Finding, Purchasing, Verifying, and Running Reserved Instances
Medium Utilization
Average
Light Utilization
Lowest
Highest overall cost if you plan to run all of the time; however it's the lowest overall cost if you anticipate you will use your Reserved Instances infrequently, more than about 11 percent over a 3-year term.
5. Run your Reserved Instance by launching an instance with the criteria you specified when you purchased your Reserved Instance. These criteria include platform, instance type, region, and Availability Zone. 6. Confirm that your instances are running as specified.
Note
If your Reserved Instance purchase crosses from one pricing tier to another, your new purchase will go into a pending state while the Reserved Instance service processes the purchase. Processing involves purchasing two or more different Reserved Instances for you: An amount at one tier, and an amount at the next tier which would be either the discounted rate or the higher discounted rate. As a result, the Reserved Instance ID returned by your purchase CLI command and API action will be different from the actual ID of the new Reserved Instances. For more information, see Understanding Reserved Instance Pricing Tiers (p. 220).
If you are new to Reserved Instances, and you want to learn about the tools need to work with Reserved Instances, see Tools and Prerequisites (p. 215). To get started finding and purchasing your Reserved Instance, see Working with Reserved Instances (p. 228).
Use the Purchase Reserved Instances page to specify the details of Reserved Instances you want to purchase.
Use the Instances page to manage the instances you launched using your Reserved Instances.
List Reserved Instances that you have purchased. ec2-describe-reserved-instances View the Reserved Instances offerings that are available for purchase. Purchase a Reserved Instance.
ec2-describe-reserved-instances-offerings
ec2-purchase-reserved-instances-offering
For information about CLI commands, see the Amazon Elastic Compute Cloud Command Line Reference.
API
To purchase Reserved Instances, you use API calls specifically designed for these tasks. To manage the instances when your Reserved Instances are launched, use the same API calls that you use for Amazon EC2 instances. The following table lists the API calls you use for Reserved Instances tasks. Task API
Amazon Elastic Compute Cloud User Guide Understanding the Pricing Benefit and Consolidated Billing
Task View the Reserved Instances offerings that are available for purchase. Purchase a Reserved Instance.
API
DescribeReservedInstancesOfferings
PurchaseReservedInstancesOffering
For information about API actions, see the Amazon Elastic Compute Cloud API Reference.
Then User A purchases the following Medium Utilization Reserved Instances: (2) m1.small instances in Availability Zone us-east-1a (3) c1.medium instances in Availability Zone us-east-1a (1) c1.xlarge instance in Availability Zone us-east-1b
In purchasing the Reserved Instances, User A pays an upfront fee for the capacity reservation so he can launch the six instances to his specifications when he needs them. In addition, he is also getting a discount on the hourly usage fees for the equivalent of six instances each month. Since he already has instances running when he purchases the Reserved Instances, Amazon EC2 will automatically apply the discounted
Amazon Elastic Compute Cloud User Guide Understanding the Pricing Benefit and Consolidated Billing
hourly rates to the already running On-Demand instances that match the specifications for the Reserved Instances he purchased. This is what happens: Amazon EC2 applies the discounted usage fee rate for two m1.small Reserved Instances that he purchased to two of the four running Amazon EC2 instances in Availability Zone us-east-1a. The other two EC2 instances in Availability Zone us-east-1a will be charged at the current On-Demand rate. Amazon EC2 doesn't apply discounted rates from the three c1.medium Reserved Instances because the c1.medium Reserved Instances are in a different Availability Zone from the running c1.medium Amazon EC2 instances. The four running c1.medium Amazon EC2 instances will be charged at the current On-Demand rate. If User A launches a c1.medium EC2 instance in Availability Zone us-east-1a, Amazon EC2 will apply the Reserved Instance discounted usage fee rate to that instance. Amazon EC2 applies the discounted usage fee rate for one c1.xlarge Reserved Instance that he purchased to one of the two running Amazon EC2 instances in Availability Zone us-east-1b. The other c1.xlarge EC2 instance in Availability Zone us-east-1b will be charged at the current On-Demand rate.
In this example scenario, by purchasing the six Reserved Instances, User A saves on the hourly fee charged against two m1.small and one c1.xlarge On-Demand EC2 instances he had already running. At the same time, he is assured of the capacity to run the six instances when he needs them.
Amazon Elastic Compute Cloud User Guide Understanding the Pricing Benefit and Consolidated Billing
User A, User B, and User C, fall under account CB AZ. In one month, the total number of instances running across all three users is 18 instances, all at the same rate. There are 30 days in a month, and the instances run 10 hours a day. This is a total of 300 hours a month. User A, the purchaser of the six Reserved Instances, is running 9 Instances, which is one-half of the total instances billed to the master account. User B is running 6 Instances, which is one-third of the total instances billed. User C is running 3 Instances, which is one-sixth of the total instances billed.
The following table shows how the consolidated bill would look without the benefit of Reserved Instances purchased by User A.
Note
Amazon EC2 doesn't determine or allocate Reserved Instances usage to a particular account. Instead, Amazon EC2 adds up the usage, calculates cost, and divides the total charges across each account.
User B
User C
With User A's purchase of Reserved Instances, the benefit of the discounted rate for six Reserved Instances will be divided across the three accounts under the master account CB AZ. The division will be based on the usage rate: User A: one-half of 6 = 3 instances User B: one-third of 6 = 2 instances User C: one-sixth of 6 = 1 instance
Master account CB AZ will save a total of $900 in usage fees after the Reserved Instances discounts are applied. The following table shows how the consolidated bill would look with the benefit of Reserved Instances purchased by User A.
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
User A
3 (instances) X 300 $450.00 (hours for the month) X $0.50 (Reserved Instance rate) = $450.00 6 (instances) X 300 (hours for the month) X $1.00= $1,800.00 Total cost: $2,250.00 2 (instances) X 300 $300.00 (hours for the month) X $0.50 (Reserved Instance rate) = $300.00 4 (instances) X 300 (hours for the month) = $1,200.00 Total cost: $1,500.00 1 (instance) X 300 $150.00 (hours for the month) X $0.50 (Reserved Instance rate) = $150.00 2 (instances) X 300 (hours for the month) = $600.00 Total cost: $750.00
User B
6 Instances Comprises one-third of total 18 instances Gets one-third of discount for 6 Reserved Instances applied
User C
3 Instances Comprises one-sixth of total 18 instances Gets one-sixth of discount for 6 Reserved Instances applied
Note
There are different pricing options for Reserved Instances, depending on the instance type, Availability Zone, term period, and product platform. For information about pricing, see the Amazon EC2 Reserved Instances product page.
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
Tier 0
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
For more information about how the benefits of Reserved Instances apply to consolidated billing accounts, see Reserved Instances and Consolidated Billing (p. 218).
Command Line Interface (CLI) Use the ec2-describe-reserved-instances command to find out the pricing tier in which your account belongs. The ec2-describe-reserved-instances command will return FixedPrice information showing the amount you paid for all your active Reserved Instances. Your ec2-describe-reserved-instances command should look like the following example:
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
API Use the DescribeReservedInstances action to find out the pricing tier in which your account belongs. The DescribeReservedInstances action will return fixedPrice information showing the amount you paid for all your active Reserved Instances. Your DescribeReservedInstances action should look like the following example:
https://ec2.amazonaws.com/ ?Action=DescribeReservedInstances &...auth parameters...
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
<start>2011-11-28T16:17:12.845Z</start> <duration>31536000</duration> <fixedPrice>227.5</fixedPrice> <usagePrice>0.03</usagePrice> <instanceCount>1</instanceCount> <productDescription>Linux/UNIX</productDescription> <state>active</state> <instanceTenancy>default</instanceTenancy> <currencyCode>USD</currencyCode> <offeringType>Medium Utilization</offeringType> <recurringCharges/> </item> ... </reservedInstancesSet> </DescribeReservedInstances>
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
The main point to keep in mind is that list price is the undiscounted price of the Reserved Instance at the time of purchase, while the fixed price value is the paid price of all Reserved Instances purchased. The discount tier is based on list price. In addition, when you purchase Reserved Instances, one of three possible scenarios will occur: Your purchase of Reserved Instances per Region is still within the lowest tier (tier 0). This means that your purchase does not reach the threshold for the discount tiers, and you don't get a discount. The process works as it does today. Your purchase of Reserved Instances within a Region crosses the threshold of the first discount tier. This means that the newly purchased Reserved Instances will go into the pending state. For this purchase, the Reserved Instances service will purchase Reserved Instances for you at two different rates: An amount at the undiscounted rate, and an amount at the discounted rate. It is important to understand that the Reserved Instance IDs you get back from the CLI or API will be different from the new Reserved Instance IDs that will actually be created. Your entire purchase of Reserved Instances within a Region is completely within a discount tier. This means that the newly purchased Reserved Instances will go into the pending state. For this purchase, the Reserved Instances service will purchase Reserved Instances at the appropriate discount level for you. It is important to understand that, as with the previous scenario, the Reserved Instance IDs you get back from the CLI or API will be different from the new Reserved Instance IDs that will actually be created.
The describe command will not recognize the Reserved Instance ID. What really happened is that the Reserved Instance service generated several Reserved Instance IDs because your purchase crossed from the undiscounted tier (tier 0) to the first discounted tier (tier 1). The portion of Reserved Instances that is in tier 1 has a 10 percent discount applied to the list price. Your entire purchase would look like the following example:
$ ec2-describe-reserved-instances -H --region sa-east-1 bbcd9749-05f0-4ada-96c8812f5f0ab9b3 Type ReservedInstancesId AvailabilityZone InstanceType ProductDescription Dura tion FixedPrice UsagePrice InstanceCount Start State Currency InstanceTenancy OfferingType RESERVEDINSTANCES bbcd9749-05f0-4ada-96c8-812f5f0ab9b3 sa-east-1a t1.micro Linux/UNIX 3y 20000.0 0.0090 2 2012-03-02T23:20:16+0000 default payment-pending USD Medium Utilization $ ec2-describe-reserved-instances -H --region sa-east-1 1ba8e2e3-346e-4e5b-a2e2b559243f2325
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
Type ReservedInstancesId AvailabilityZone InstanceType ProductDescription Dura tion FixedPrice UsagePrice InstanceCount Start State Currency InstanceTenancy OfferingType RESERVEDINSTANCES 1ba8e2e3-346e-4e5b-a2e2-b559243f2325 sa-east-1a t1.micro Linux/UNIX 3y 18000.0 0.0080 3 2012-03-02T23:20:17+0000 default payment-pending USD Medium Utilization $ ec2-describe-reserved-instances -H --region sa-east-1 af9f760e-868c-48f4-87e244576dbf05ef tType ReservedInstancesId AvailabilityZone InstanceType ProductDescription Duration FixedPrice UsagePrice InstanceCount Start State Currency InstanceTenancy OfferingType RESERVEDINSTANCES af9f760e-868c-48f4-87e2-44576dbf05ef sa-east-1a t1.micro Linux/UNIX 3y 18000.0 0.0080 5 2012-03-02T23:20:18+0000 default payment-pending USD Medium Utilization
Reserved Instance ID bbcd9749-05f0-4ada-96c8-812f5f0ab9b3 is the ID for the Reserved Instances that you purchased at the undiscounted list price of $20,000 each. Reserved Instance IDs 1ba8e2e3-346e-4e5b-a2e2-b559243f2325 and af9f760e-868c-48f4-87e2-44576dbf05ef are the IDs for the Reserved Instances that you purchased at the 10 percent discount rate ($20,000 minus $2,000).
Later you want to purchase more Reserved Instances. Let's say that AWS lowered prices and the same type of Reserved Instance now is available at $1000 each.You purchase 75 of these Reserved Instances. The List Price for this purchase is $1000. The purchase of 75 Reserved Instances at $1000 each totals $75,000. This raises the total cost of your active Reserved Instances to $275,000. The threshold for the discount tier is $250,000. This purchase crosses you into the discount tier, also called tier 1 in the Reserved Instance Pricing Tiers (p. 221) table. In this discount tier, you get a 10 percent discount on all your purchases of Reserved Instances in the same Region above $250,000. So, you will pay the new list price of $1000 each for the first 50 Reserved Instances (total amount paid of $50,000). And you will pay $900 eachthe $1000 list price minus the 10 percent discount for the remaining 25 Reserved Instances (total amount paid of $22,500). Your fixed price and the price paid for the discounted Reserved Instances will both show $900. The following table illustrates this example. Purchase Number Purchase 1 List Price $2000 Amount Paid $2000 Fixed Price $2000 Total RI Purchased 100 Total List Price Cost $200,000 Total Paid Amount $200,000
Amazon Elastic Compute Cloud User Guide Understanding Reserved Instance Pricing Tiers
Total RI Purchased 50 25
Totals
Six months later, let's assume that your business experiences tremendous growth, and you need to purchase 1800 additional Reserved Instances in the same Region. At a list price of $1000, this purchase will total $1,800,000. When you add this new purchase to your previous purchases of already active Reserved Instances that total $272,500, your new total will be $2,072,500. This new total crosses the threshold for the next discount tier (tier 2 in the Reserved Instance Pricing Tiers (p. 221) table). In this tier, discounts of 20 percent apply to purchases above $2,000,000. Your new purchase will be charged two different discount rates: The 1725 Reserved Instances that fall within tier 1 will be discounted 10 percent. The remaining 75 Reserved Instances that put the total list price cost above $2,000,000, and thus in tier 2, will be discounted 20 percent. Purchase Number Purchase 1 Purchase 2 List Price $2000 $1000 $1000 Purchase 3 $1000 $1000 Amount Paid $2000 $1000 $900 $900 $800 Fixed Price $2000 $1000 $900 $900 $800 Total RI Purchased 100 50 25 1725 75 Total Total List Price Cost $200,000 $50,000 $25,000 $1,725,000 $75,000 $2,075,000 Total Paid Amount $200,000 $50,000 $22,500 $1,552,500 $60,000 $1,885,000
Current Limitations
The following limitations currently apply: Reserved Instance ID: If your Reserved Instance purchase crosses into a discount pricing tier or crosses into a new discount pricing tier, your new purchase will go into a pending state while the Reserved Instance service processes the purchase. Processing involves purchasing two or more different Reserved Instances for you: An amount at either the undiscounted rate or the lower discounted rate, and an amount at either the discounted rate or the higher discounted rate. Describe Reserved Instances: The Reserved Instance ID returned by your purchase CLI command and API action will be different from the actual ID of the new Reserved Instances.
Amazon Elastic Compute Cloud User Guide Working with Reserved Instances
Amazon EC2 Reserved Instance purchases are the only purchases that will apply toward your Amazon EC2 Reserved Instance pricing tiers. And the Amazon EC2 Reserved Instance pricing tiers apply only to Amazon EC2 Reserved Instance purchases. Amazon EC2 Reserved Instance pricing tiers do not apply to instances running Microsoft SQL Server. Amazon EC2 Reserved Instances purchased as part of a tiering discount cannot be sold in the Reserved Instance Marketplace. For more information about the Reserved Instance Marketplace, see Reserved Instance Marketplace (p. 234).
4.
Locate a Reserved Instance to purchase by specifying the following: Platform (if you want to use the Reserved Instance with Amazon Virtual Private Cloud, make sure to select a platform that includes Amazon VPC in its name) Instance Type Availability Zone Term Tenancy (For more information, see Dedicated Instances Basics in the Amazon Virtual Private Cloud User Guide.) Offering Type (For more information, see Reserved Instances Offerings (p. 213).)
Amazon Elastic Compute Cloud User Guide Working with Reserved Instances
5.
Click Search to get a list of Reserved Instances available for purchase that meet your specifications. The Purchase Reserved Instances wizard returns a list of available Reserved Instances that meet your specifications, and the list can include third-party offerings that are available through the Reserved Instance Marketplace. For more information about Reserved Instance Marketplace, see Reserved Instance Marketplace (p. 234). Select the Reserved Instances that you are interested in, enter the quantity that you want to purchase, and click Add to Cart. You can continue to select more Reserved Instances and add them to your cart.
6.
Click Purchase when you have all the Reserved Instances you want to purchase, and you want to check out. The Purchase Reserved Instances wizard confirms your order.
Amazon Elastic Compute Cloud User Guide Working with Reserved Instances
7.
The Reserved Instances page displays a list of Reserved Instances that belong to your account.
You can run your Reserved Instance any time after your purchase is complete. To run your Reserved Instance, you launch an instance in the same way you launch an On-Demand instance. Make sure to specify the same criteria that you specified for your Reserved Instance. AWS will automatically charge you the lower hourly rate.
Amazon Elastic Compute Cloud User Guide Working with Reserved Instances
OFFERING 4b2293b4-ff40-4a1a-9fef-1f12ad37a711 us-east-1b c1.medium 3y 0.06 Linux/UNIX USD default Medium Utilization OFFERING 60dcfab3-71e1-42cd-bd3e-f5e1e61ec5a8 us-east-1b c1.medium 3y 0.125 Windows (Amazon VPC) USD default Medium Utilization OFFERING 649fd0c8-cafc-4060-ace6-a074c9621f75 us-east-1b c1.medium 3y 0.155 Windows (Amazon VPC) USD dedicated Medium Utilization ...
The preceding output shows a part of the overall offerings that are available. Here we show both 3-year (3y) and 1-year (1y) Reserved Instances available for m1.small instances in either the us-east-1b or us-east-1d Availability Zones.
Important
If you want to use the Reserved Instance with Amazon Virtual Private Cloud, make sure to select an offering that includes Amazon VPC in the description (e.g., Linux/UNIX (Amazon VPC)).
Tip
You can filter this list to return only certain types of Reserved Instances offerings of interest to you. For more information about how to filter the results, see ec2-describe-reserved-instances-offerings in the Amazon Elastic Compute Cloud Command Line Reference. 2. From the list of available Reserved Instances, purchase the Reserved Instances that meet your requirements. To purchase a Reserved Instance, use ec2-purchase-reserved-instances-offering.
PROMPT> ec2-purchase-reserved-instances-offering --offering offering_id -instance-count count
3. 4.
The response includes the offering ID and a reservation ID. Write down or save the reservation ID for future reference. Verify the purchase:
PROMPT> ec2-describe-reserved-instances
You can run your Reserved Instance any time after your purchase is complete. To run your Reserved Instance, you launch an instance in the same way you launch an On-Demand instance. Make sure to specify the same criteria that you specified for your Reserved Instance. AWS will automatically charge you the lower hourly rate.
Amazon Elastic Compute Cloud User Guide Working with Reserved Instances
API
To find and purchase a Reserved Instance
1. Check to see which Reserved Instances are available and where they are located using the following Query request.
https://ec2.amazonaws.com/ ?Action=DescribeReservedInstancesOfferings &...auth parameters...
Following is an example response (note that the duration is in seconds; 31536000 seconds equals 1 year).
<DescribeReservedInstancesOfferings xmlns="http://ec2.amazonaws.com/doc/201302-01/"> <reservedInstancesOfferingsSet> <item> <reservedInstancesOfferingId>438012d3-80c7-42c6-9396a209c58607f9</reservedInstancesOfferingId> <instanceType>m1.small</instanceType> <availabilityZone>us-east-1b</availabilityZone> <duration>31536000</duration> <fixedPrice>227.5</fixedPrice> <usagePrice>0.03</usagePrice> <productDescription>Linux/UNIX</productDescription> </item> ... </reservedInstancesOfferingsSet> </DescribeReservedInstancesOfferings>
Important
If you want to use the Reserved Instance with Amazon Virtual Private Cloud, make sure to select an offering that includes Amazon VPC in the product description (e.g., Linux/UNIX (Amazon VPC)).
Tip
You can filter this list to return only certain types of Reserved Instances offerings of interest to you. For more information about how to filter the results, see DescribeReservedInstancesOfferings in the Amazon Elastic Compute Cloud API Reference. 2. From the list of available Reserved Instances, purchase an offering using a Query request similar to the following.
https://ec2.amazonaws.com/ ?Action=PurchaseReservedInstancesOffering &ReservedInstancesOfferingId=438012d3-80c7-42c6-9396-a209c58607f9 &instanceCount=2 &...auth parameters...
Amazon Elastic Compute Cloud User Guide Working with Reserved Instances
stancesId> </PurchaseReservedInstancesOffering>
3.
Following is an example response (note that the duration is in seconds; 31536000 seconds equals 1 year):
<DescribeReservedInstances xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <reservedInstancesSet> <item> <reservedInstancesId>af9f760e-c1c1-449b-8128-1342d3a6927a</reservedIn stancesId> <instanceType>m1.small</instanceType> <availabilityZone>us-east-1b</availabilityZone> <duration>31536000</duration> <usagePrice>227.5</usagePrice> <fixedPrice>0.03</fixedPrice> <instanceCount>2</instanceCount> <productDescription>Linux/UNIX</productDescription> <state>Active</state> </item> </reservedInstancesSet> </DescribeReservedInstances>
You can run your Reserved Instance any time after your purchase is complete. To run your Reserved Instance, you launch an instance in the same way you launch an On-Demand instance. Make sure to specify the same criteria that you specified for your Reserved Instance. AWS will automatically charge you the lower hourly rate.
Related Topics
Reserved Instances FAQs (p. 603)
Note
Only Amazon EC2 Reserved Instances can be sold in the Reserved Instance Marketplace. Other AWS Reserved Instances, such as Amazon Relational Database Service (Amazon RDS) and Amazon ElastiCache Reserved Instances cannot be sold on the Reserved Instance Marketplace. This section discusses the basics of the Reserved Instance Marketplace: How the Reserved Instance Marketplace Works: Seller Overview (p. 235) Selling in the Reserved Instance Marketplace (p. 236) How the Reserved Instance Marketplace Works: Buyer Overview (p. 235) Buying in the Reserved Instance Marketplace (p. 263)
For information about Reserved Instances, see Reserved Instances (p. 212).
Amazon Elastic Compute Cloud User Guide How the Reserved Instance Marketplace Works: Seller Overview
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Amazon EC2 Reserved Instances purchased as part of a tiering discount cannot be sold in the Reserved Instance Marketplace. For more information information about the Reserved Instance Marketplace, see Reserved Instance Marketplace (p. 234).
Registering as a Seller
Topics Your Bank (p. 238) Tax Information (p. 239) Seller Registration Confirmation (p. 240) Sharing Information with the Buyer (p. 240) Next Steps (p. 241) To be able to sell in the Reserved Instance Marketplace, your first task is to register as a seller.
Registering means providing the name of your business, information about your bank, and your business's tax identification number. Usually, you only have to provide your information once. However, you can update personal and banking information in the Seller Settings page of Account Settings in the AWS Management Console. If you haven't created an AWS account yet, do this first before you register for Reserved Instance Marketplace. Complete the instructions described in Getting Started with EC2, which provides information about creating your Amazon EC2 account and credentials. You can access the registration process through the Reserved Instance Marketplace Seller Registration web page. If you try to create a listing and you have not registered, AWS will direct you to this seller registration page.
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Your Bank
AWS must have your bank information in order to disburse funds collected when you sell your Reserved Instance. The bank you specify must have a US address.
Provide the following information about the bank through which you will receive payment: Bank Account Holder Name Routing Number Account Number Bank Account Type Specify if the bank is a personal or corporate account.
API Version 2013-02-01 238
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
If the bank is your personal account, provide your driver's license number and the state that issued it. If you are using a corporate bank account, you will be prompted to send via fax (1-206-765-3424) the information about the bank account.
You can change the default bank account through which you receive disbursements. Just go to the AWS Management Console and change the Disbursement Settings under the Seller Setting. After you have completed the registration, AWS verifies your bank account and sets it as the default bank. You will not be able to receive disbursements until AWS has verified your account with the bank. Verification with the bank can take up to two weeks, so if your account is a new one, you will not get the disbursement as a result of a sale for up to two weeks. For an established account, it will usually take about two days for disbursements to complete.
Tax Information
Your sale of Reserved Instances on the Reserved Instance Marketplace might be subject to a transactional tax, such as sales tax or value-added tax. You should check with your business's tax, legal, finance, or accounting department to determine if transaction-based taxes are applicable. You are responsible for collecting and sending the transaction-based taxes to the appropriate tax authority. As part of the seller registration process, you have the option of completing a tax interview. We encourage you to complete this process if any of the following apply: You want AWS to generate a Form 1099-K. You anticipate having either 200 or more transactions or $20,000 or more in sales of Reserved Instances in a calendar year. A transaction can involve one or more Reserved Instances. If you choose to skip this step during registration, and later you reach transaction 199, you will get a message saying, "You have reached the transaction limit for pre-tax. Please complete the tax interview at http://portal.aws.amazon.com/ec2/ri/seller_registration?action=taxInterview ." You are a non-U.S. seller. In this case, you must electronically complete Form W-8BEN. If you complete the tax interview, the tax information you enter will differ depending on whether your business is a U.S. or non-U.S. legal entity. If you are a U.S. seller, you must provide AWS with your tax identification number along with your business contact information.
After you complete the tax registration process, AWS will file Form 1099-K, and you will receive a copy of it through the U.S. mail on or before January 31 in the year after the year that your tax account reaches the threshold levels. As you fill out the tax interview, keep in mind the following:
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Information provided by AWS, including the information in this topic, does not constitute tax, legal, or other professional advice. To find out how the IRS reporting requirements might affect your business, or if you have other questions, please contact your tax, legal, or other professional advisor. In order to fulfill the IRS reporting requirements as efficiently as possible, answer all questions and enter all information requested during the interview. Check your answers. Avoid misspellings or entering incorrect tax identification numbers. They can result in an invalidated tax form.
For more information about IRS requirements and the Form 1099-K, see the IRS website.
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Next Steps
After you have successfully registered as a seller in the Reserved Instance Marketplace, you can begin selling your Reserved Instances. Selling in the Reserved Instance Marketplace requires the following steps: 1. Deciding which Reserved Instances you want to sell. Identify the active Reserved Instances that you want to sell and select the upfront price at which you want to sell them. For more information, see Pricing Your Reserved Instances (p. 242). 2. Listing your Reserved Instances. Include your Reserved Instance in the Reserved Instance Marketplace listings. For more information, see Listing Your Reserved Instance (p. 242). 3. Viewing, canceling, and changing your listings. You can monitor your Reserved Instances and change your listings. For more information, see Viewing, Canceling, and Changing Your Listings (p. 251). For information about selling your Reserved Instances, see Selling Your Reserved Instances (p. 241).
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
The DescribeReservedInstances API action. For more information about Reserved Instances, see Reserved Instances (p. 212).
AWS Management Console To list a Reserved Instance in the Reserved Instance Marketplace
1. 2. 3. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. Click Reserved Instances in the Navigation pane. The Reserved Instances page displays a list of your account's instances. Select the Reserved Instances you want to list on the Marketplace, and click Sell Reserved Instances.
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Note
If you have not completed the Reserved Instance Marketplace seller registration process, you will be prompted to complete this process now. For information about the seller registration process, see Registering as a Seller (p. 237). 4. In the Configure Your Reserved Instance Listing page, for Number to List, set the number of instances to sell and, for Your Price, set the upfront price for the remaining time period.
5.
You can see how the value of your Reserved Instance will change over the remainder of the term by clicking the arrow on the left of the Months Remaining column. By default, AWS sets the price to decrease linearly. This means the price drops by equal increments each month. If you are an advanced user and you want to customize the pricing, you can enter a different value for the subsequent months. To return to the default linear price drop, click the Reset button. Click Continue when you are finished configuring your listing.
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
6.
When you are satisfied with the details of your listing as displayed by the Confirm Your Reserved Instance Listing screen, click List Reserved Instance. You will get a confirmation that your listing is being processed.
7.
To view the details of your Reserved Instance listing, on the Reserved Instances page, select the Reserved Instance you want to view, and click the My Listings tab in the bottom pane.
Amazon EC2 CLI To list a Reserved Instance in the Reserved Instance Marketplace
1. Get a list of your Reserved Instances by calling ec2-describe-reserved-instances.
PROMPT> ec2-describe-reserved-instances --headers
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
ceTenancy OfferingType RESERVEDINSTANCES f127bd27-9f30-41d3-bf45-9af45example sa-east-1a m1.large Linux/UNIX 10m 1.0 0.0 1 2012-08-22T21:41:51+0000 active USD default Medium Utilization RESERVEDINSTANCES 1ba8e2e3-d20d-44ec-b202-fcb6aexample sa-east-1b m1.small Linux/UNIX 10m 1.2 0.032 3 2012-08-21T14:02:00+0000 retired USD default Medium Utilization RESERVEDINSTANCES 4357912c-6f69-4966-a407-6f0cbexample sa-east-1b m1.small Linux/UNIX 10m 1.2 0.032 3 2012-08-21T14:02:00+0000 active USD default Medium Utilization RESERVEDINSTANCES 4357912c-d032-4a97-9b49-5eb3aexample sa-east-1b m1.small Linux/UNIX 10m 1.2 0.032 1 2012-08-21T14:02:00+0000 retired USD default Medium Utilization ...
2.
Select the Reserved Instance ID of the Reserved Instance you want to list in the Reserved Instance Marketplace. Specify the Reserved Instance ID of the Reserved Instance you want to list and call ec2-create-reserved-instances-listing. You have to specify the following required parameters: Reserved Instance ID Instance count MONTH:PRICE The command should look like this example:
PROMPT> ec2-create-reserved-instances-listing --reserved-instance b847fa93c736-4eae-bca1-3147example --instance-count 1 05:01.20 04:01.00 01:00.75 -headers
3.
To view the details of your Reserved Instance listing, run ec2-describe-reserved-instances-listings with the listing ID 095c0e18-c9e6-4692-97e5-653e0example.
PROMPT> ec2-describe-reserved-instances-listings 095c0e18-c9e6-4692-97e5653e0example
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Amazon EC2 API To list a Reserved Instance in the Reserved Instance Marketplace
1. Get a list of your Reserved Instances by calling DescribeReservedInstances.
https://ec2.amazonaws.com/ ?Action=DescribeReservedInstances &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
2.
Note the Reserved Instance ID of the Reserved Instance you want to list in the Reserved Instance Marketplace. Create a listing for 3 Reserved Instances from Reserved Instance ID f127bd27-cee4-443a-a76b-a5af9example and specify the following pricing schedule. Term (remaining months) Price specified for period Price 11 10 9 8 7 6 5 4 3 2 1
2.5
2.0
1.5
0.7
0.1
2.5
2.5
2.5
2.0
2.0
2.0
1.5
1.5
0.7
0.7
0.1
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<item> <state>Pending</state> <instanceCount>0</instanceCount> </item> </instanceCounts> <priceSchedules> <item> <term>11</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>true</active> </item> <item> <term>10</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>9</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>8</term> <price>2.00</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>7</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>6</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>5</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>4</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>3</term> <price>0.7</price> <currencyCode>USD</currencyCode>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<active>false</active> </item> <item> <term>2</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>1</term> <price>0.1</price> <currencyCode>USD</currencyCode> <active>false</active> </item> </priceSchedules> <tagSet/> <clientToken>listRI1</clientToken> </item> </reservedInstancesListingsSet> </CreateReservedInstancesListingResponse>
3.
To view the details of your Reserved Instance listing, run DescribeReservedInstancesListings. The command should look like this example:
http://ec2.amazonaws.com/?Action=DescribeReservedInstancesListings &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<state>Pending</state> <instanceCount>0</instanceCount> </item> </instanceCounts> <priceSchedules> <item> <term>11</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>true</active> </item> <item> <term>10</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>9</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>8</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>7</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>6</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>5</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>4</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>3</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
</item> <item> <term>2</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>1</term> <price>0.1</price> <currencyCode>USD</currencyCode> <active>false</active> </item> </priceSchedules> <tagSet/> <clientToken>listRI1</clientToken> </item> </reservedInstancesListingsSet> </DescribeReservedInstancesListingsResponse>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
PROMPT> ec2-describe-reserved-instances-listings Type ReservedInstancesListingId ReservedInstancesId CreateDate UpdateDate Status StatusMessage LISTING 615d8a10-8224-4c19-ba7d-b9aa0example 1ba8e2e3-d20d-44ec-b202fcb6aexample Wed Aug 22 09:02:58 PDT 2012 Wed Aug 22 14:24:26 PDT 2012 can celled cancelled INSTANCE-COUNT available 0 INSTANCE-COUNT sold 0 INSTANCE-COUNT cancelled 1 INSTANCE-COUNT pending 0 PRICE-SCHEDULE 10 $1.2 PRICE-SCHEDULE 9 $1.08 PRICE-SCHEDULE 8 $0.96 PRICE-SCHEDULE 7 $0.84 PRICE-SCHEDULE 6 $0.72 PRICE-SCHEDULE 5 $0.6 PRICE-SCHEDULE 4 $0.48 PRICE-SCHEDULE 3 $0.36 PRICE-SCHEDULE 2 $0.24 PRICE-SCHEDULE 1 $0.12 LISTING d5fa5166-83c3-40e4-abb2-b7298example 1ba8e2e3-d20d-44ec-b202fcb6aexample Wed Aug 22 14:31:55 PDT 2012 Wed Aug 22 14:42:40 PDT 2012 closed closed INSTANCE-COUNT available 0 INSTANCE-COUNT sold 1 INSTANCE-COUNT cancelled 0 INSTANCE-COUNT pending 0 PRICE-SCHEDULE 10 $0.9 PRICE-SCHEDULE 9 $0.81 PRICE-SCHEDULE 8 $0.72 PRICE-SCHEDULE 7 $0.63 PRICE-SCHEDULE 6 $0.54 PRICE-SCHEDULE 5 $0.45 PRICE-SCHEDULE 4 $0.36 PRICE-SCHEDULE 3 $0.27 PRICE-SCHEDULE 2 $0.18 PRICE-SCHEDULE 1 $0.09 .... LISTING 095c0e18-c9e6-4692-97e5-653e0example b847fa93-c736-4eae-bca1e3147example Tue Aug 28 18:21:07 PDT 2012 Tue Aug 28 18:21:07 PDT 2012 active active INSTANCE-COUNT available 1 INSTANCE-COUNT sold 0 INSTANCE-COUNT cancelled 0 INSTANCE-COUNT pending 0 PRICE-SCHEDULE 5 $1.2 PRICE-SCHEDULE 4 $1.2 PRICE-SCHEDULE 3 $1.2 PRICE-SCHEDULE 2 $1.2 PRICE-SCHEDULE 1 $1.2
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<status>active</status> <statusMessage>active</statusMessage> <instanceCounts> <item> <state>Available</state> <instanceCount>2</instanceCount> </item> <item> <state>Sold</state> <instanceCount>1</instanceCount> </item> <item> <state>Cancelled</state> <instanceCount>0</instanceCount> </item> <item> <state>Pending</state> <instanceCount>0</instanceCount> </item> </instanceCounts> <priceSchedules> <item> <term>11</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>true</active> </item> <item> <term>10</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>9</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>8</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>7</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>6</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<term>5</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>4</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>3</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>2</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>1</term> <price>0.1</price> <currencyCode>USD</currencyCode> <active>false</active> </item> </priceSchedules> <tagSet/> <clientToken>listRI1</clientToken> </item> </reservedInstancesListingsSet> </DescribeReservedInstancesListingsResponse>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<reservedInstancesListingsSet> <item> <reservedInstancesListingId>5ec28771-05ff-4b9b-aa319e57dexample</reservedInstancesListingId> <reservedInstancesId>f127bd27-cee4-443a-a76b-a5af9example</re servedInstancesId> <createDate>2012-08-30T17:11:09.449Z</createDate> <updateDate>2012-08-31T14:12:23.468Z</updateDate> <status>cancelled</status> <statusMessage>cancelled</statusMessage> <instanceCounts> <item> <state>Available</state> <instanceCount>0</instanceCount> </item> <item> <state>Sold</state> <instanceCount>1</instanceCount> </item> <item> <state>Cancelled</state> <instanceCount>2</instanceCount> </item> <item> <state>Pending</state> <instanceCount>0</instanceCount> </item> </instanceCounts> <priceSchedules> <item> <term>11</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>10</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>9</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>8</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>7</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
</item> <item> <term>6</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>5</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>4</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>3</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>2</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>1</term> <price>0.1</price> <currencyCode>USD</currencyCode> <active>false</active> </item> </priceSchedules> <tagSet/> <clientToken>listRI1</clientToken> </item> </reservedInstancesListingsSet> </CancelReservedInstancesListingResponse>
In the response to the Cancel request, you see the canceled listing. Another way to see that canceled listing is by calling DescribeReservedInstancesListings.The request will look like this example:
http://ec2.amazonaws.com/?Action=DescribeReservedInstancesListings &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<reservedInstancesListingId>5ec28771-05ff-4b9b-aa319e57dexample</reservedInstancesListingId> <reservedInstancesId>f127bd27-cee4-443a-a76b-a5af9example</re servedInstancesId> <createDate>2012-08-30T17:11:09.449Z</createDate> <updateDate>2012-08-31T14:12:23.468Z</updateDate> <status>cancelled</status> <statusMessage>cancelled</statusMessage> <instanceCounts> <item> <state>Available</state> <instanceCount>0</instanceCount> </item> <item> <state>Sold</state> <instanceCount>1</instanceCount> </item> <item> <state>Cancelled</state> <instanceCount>2</instanceCount> </item> <item> <state>Pending</state> <instanceCount>0</instanceCount> </item> </instanceCounts> <priceSchedules> <item> <term>11</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>10</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>9</term> <price>2.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>8</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>7</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
<term>6</term> <price>2.0</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>5</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>4</term> <price>1.5</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>3</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>2</term> <price>0.7</price> <currencyCode>USD</currencyCode> <active>false</active> </item> <item> <term>1</term> <price>0.1</price> <currencyCode>USD</currencyCode> <active>false</active> </item> </priceSchedules> <tagSet/> <clientToken>listRI1</clientToken> </item> </reservedInstancesListingsSet> </DescribeReservedInstancesListingsResponse>
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Getting Paid (p. 262) Notifications (p. 262) When your Reserved Instance is sold, AWS will send you an email notification. Each day that there is any kind of activity (for example, you create a listing; you sell a listing; or AWS sends funds to your account), you will get one email notification capturing all the activities of the day. For more information, see Notifications (p. 262). You can track the status of your Reserved Instance listings by looking at the My Listings tab of the selected Reserved Instance on the Reserved Instance page in the Amazon EC2 console. The tab contains the Listing State information. You can also use the ec2-describe-reserved-instances-listings CLI command or the DescribeReservedInstancesListings API call, with the appropriate filter to see the state of your Reserved Instances. Listing State can display any of the following statuses for your Reserved Instance listings: ActiveThe listing is available for purchase. CancelledThe listing is cancelled and won't be available for purchase in the marketplace. ClosedThe Reserved Instance is not listed. A Reserved Instance might be Closed because the sale of the listing was completed.
Lifecycle of Listings
Now that you have created listings, let's walk through what happens when your listing sells. When all the instances in your listing are matched and sold, the My Listings tab shows that your Total instance count matches the count listed under Sold, there are no Available instances left for your listing, and its Status is closed. When only a portion of your listing is sold, AWS retires the Reserved Instances in the listing and creates a new Reserved Instance for the remaining instance count that are still available for sale. So, the Reserved Instances listing ID and the listing that it represents, which now has an instance count of fewer instances for sale, is still active. Any future sales of Reserved Instances in this listing are processed this way. When all the Reserved Instances in the listing are sold, AWS marks the listing as closed. For example, let's say you created a listing Reserved Instances listing ID 5ec28771-05ff-4b9b-aa31-9e57dexample with an instance count of 5. Your My Listings tab in the Reserved Instance page of the Amazon EC2 console will display the listing this way: Reserved Instance listing ID 5ec28771-05ff-4b9b-aa31-9e57dexample Total instance count = 5 Sold = 0 Available = 5 Status = active Let's say that a buyer purchases two of the instances, which leaves a count of three instances still available for sale. As a result of this partial sale, AWS creates a new Reserved Instance with an instance count of three to represent the remaining three that are still for sale. This is how your listing will look in your My Listings tab:
API Version 2013-02-01 261
Amazon Elastic Compute Cloud User Guide Selling in the Reserved Instance Marketplace
Reserved Instance listing ID 5ec28771-05ff-4b9b-aa31-9e57dexample Total instance count = 5 Sold = 2 Available = 3 Status = active If you decide to cancel your listing and a portion of that listing has already sold, only that portion of the listing that has not yet been sold will no longer be available in the Reserved Instance Marketplace.
Getting Paid
As soon as AWS receives funds from the buyer of your Reserved Instance, AWS sends a message to your email addressthat is, the email address associated with the account that is registered as owner of the Reserved Instance that was sold. AWS sends an Automated Clearing House (ACH) wire transfer to the bank account that you specified when you registered for the Reserved Instance Marketplace. Typically, this transfer occurs between one to three days after your Reserved Instance has been matched.You can view the state of this disbursement by viewing your Reserved Instance disbursement report. Disbursements take place once a day. Keep in mind that you will not be able to receive disbursements until AWS has received verification from your bank. This period can take up to two weeks. The Reserved Instance you sold will continue to appear in the results of DescribeReservedInstances calls you make for another 60 days before disappearing from the list. You will receive a pro-rated refund for the portion of the upfront fee you paid for the Reserved Instance that you did not use.
Notifications
As a seller in the Reserved Instance Marketplace, you will receive an email digest of the Reserved Instance Marketplace activities pertaining to your account. On any given day, you will receive one email digest, and you will only receive such an email if one or a combination of activities occurred that day: You created a new listing in the Reserved Instance Marketplace. You sold one or more of the Reserved Instances you listed. AWS posted a disbursement to your bank account as a result of a sale of part or all of your listing in the Reserved Instance Marketplace. Your email digest will look similar to this:
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
this failed transaction by showing that the Reserved Instance you attempted to purchase will move from the payment-pending to the payment-failed state. It is important to note that once you have purchased a Reserved Instance (from a third-party seller in the Reserved Instance Marketplace or from AWS), you cannot cancel your purchase. However, you can always re-list and sell the Reserved Instance if your needs change. For information about selling your Reserved Instance in the Reserved Instance Marketplace, see Selling in the Reserved Instance Marketplace (p. 236).
Becoming a Buyer
Topics Understanding the Information You Will Disclose (p. 264) Next Steps (p. 264) Becoming a buyer in the Reserved Instance Marketplace is simple and easy. If you already have an AWS account, you are ready to start purchasing from the Reserved Instance Marketplace. For more information, see the following sections: Understanding the Information You Will Disclose (p. 264) Purchasing Your Reserved Instances (p. 264) If you don't have an Amazon Web Services (AWS) account, you first have to sign up and create an account with AWS. For more information, see Getting Started with EC2.
Next Steps
After you have signed up with AWS, you can begin buying Reserved Instances in the Reserved Instance Marketplace. To find the Reserved Instances that address your specific business needs, see Purchasing Your Reserved Instances (p. 264). To understand your invoice, see Reading Your Statement (Invoice) (p. 271). To sell your unused Reserved Instances, see Selling in the Reserved Instance Marketplace (p. 236). For information about Reserved Instances, see Reserved Instances (p. 212).
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
Amazon EC2 CLI (p. 267) Amazon EC2 API (p. 269) The procedure for buying Amazon EC2 Reserved Instances from third parties in the Reserved Instance Marketplace is essentially the same as the procedure for purchasing Reserved Instances from Amazon Web Services (AWS). In this section, you will go through the same process that is discussed in Working with Reserved Instances (p. 228) using the AWS Management Console, Amazon EC2 CLI, and Amazon EC2 API tools. However, we will highlight the expanded options and features that are added when you purchase from third parties in the Reserved Instance Marketplace.
4.
In the Purchase Reserved Instances page, specify the details of the Reserved Instances you want to purchase (such as familiar filters like Platform, Instance Type, Availability Zone, Term, and Tenancy), and click Search.
The Purchase Reserved Instances wizard will display a list of Reserved Instances that meet your search criteria.
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
5.
Select the Reserved Instances that you are interested in, enter the quantity that you want to purchase, and click Add to Cart. You can continue to select more Reserved Instances and add them to your cart. The Seller column indicates whether the seller is a 3rd Party or AWS. Notice that Term gives you a wide choice of terms, based on whether the seller is a third party or AWS. At the bottom of the page, the Purchase Reserved Instances wizard keeps a running tally of the total in your cart.
6.
Click View Cart to see a summary of the Reserved Instances that you have selected. If you want to add more Reserved Instances to your cart, click Add More To Cart. If you want to remove an item from your cart, click Delete. Or, click Cancel if you want to start over or search for a different set of Reserved Instances.
7.
Click Purchase when you have all the Reserved Instances you want to purchase, and you want to check out.
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
Note that if at the time of purchase, there are offerings similar to your choice but with a lower price, AWS will give you the offerings with the lower price.
8.
Your purchase is complete. To verify your order, go to the Reserved Instances page in the EC2 console.
The Reserved Instances page displays a list of Reserved Instances that belong to your account, including the new Reserved Instance that you just purchased. You can use your Reserved Instance any time after your purchase is complete. This means that the State of your Reserved Instance has changed from payment-pending to active. To use your Reserved Instance, you launch an instance in the same way you launch an On-Demand instance. Just make sure to specify the same criteria that you specified for your Reserved Instance. AWS will automatically charge you the lower hourly rate. You do not have to restart your instance.
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
PROMPT> ec2-describe-reserved-instances-offerings Type Source ReservedInstancesOfferingId AvailabilityZone InstanceType Duration FixedPrice UsagePrice ProductDescription Currency InstanceTenancy Offering Type OFFERING AWS 4b2293b4-3236-49f5-978d-a74c3example sa-east-1b m1.small 3y 574.0 0.0 Linux/UNIX USD default Heavy Utilization Type Frequency Amount RECURRING-CHARGE Hourly 0.021 OFFERING AWS 3a98bf7d-07e1-4b33-8e11-e5314example sa-east-1b m1.small 3y 473.0 0.031 Linux/UNIX USD default Medium Utilization OFFERING AWS 438012d3-5fc5-4e49-a88e-273edexample sa-east-1b m1.small 3y 203.0 0.055 Linux/UNIX USD default Light Utilization OFFERING AWS d586503b-bb92-41fa-9065-e5b90example sa-east-1b m1.small 1y 372.94 0.0 Linux/UNIX USD default Heavy Utilization Type Frequency Amount RECURRING-CHARGE Hourly 0.03 OFFERING AWS ceb6a579-b235-41e2-9aad-15a23example sa-east-1b m1.small 1y 307.13 0.04 Linux/UNIX USD default Medium Utilization OFFERING AWS 649fd0c8-4ffb-443d-824d-eae3fexample sa-east-1b m1.small 1y 131.63 0.07 Linux/UNIX USD default Light Utilization OFFERING 3rd Party b6121943-9faf-4350-8047-bc6d4example sa-east-1b m1.small 10m - 0.032 Linux/UNIX USD default Medium Utilization Type Count Price PRICING_DETAIL 2 $1.2 OFFERING 3rd Party 08edcff2-8143-4c1d-b23c-e4c11example sa-east-1b m1.small 5m - 0.032 Linux/UNIX USD default Medium Utilization Type Count Price PRICING_DETAIL 19 $1.2 PRICING_DETAIL 4 $1.23
The preceding output shows a part of the overall offerings that are available.
Tip
You can filter this list to return only certain types of Reserved Instances offerings of interest to you. For more information about how to filter the results, see ec2-describe-reserved-instances-offerings in the Amazon Elastic Compute Cloud Command Line Reference. 2. From the list of available Reserved Instances, purchase the Reserved Instances that meet your requirements. To purchase a Reserved Instance, use the following command.
PROMPT> ec2-purchase-reserved-instances-offering --offering offering --in stance-count count
3. 4.
The response includes the offering ID and a reservation ID. Write down and save the reservation ID for future reference. Verify the purchase.
PROMPT> ec2-describe-reserved-instances
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
You can run your Reserved Instance any time after your purchase is complete. To run your Reserved Instance, you launch it in the same way you launch an On-Demand instance. Make sure to specify the same criteria that you specified for your Reserved Instance. AWS will automatically charge you the lower hourly rate.
Note
When using the Query API the / is denoted as %2F. Following is an example response.
<DescribeReservedInstancesOfferingsResponse xmlns='http://ec2.amazon aws.com/doc/2012-08-15/'> <requestId>768e52ac-20f5-42b1-8559-e70e9example</requestId> <reservedInstancesOfferingsSet> <item> <reservedInstancesOfferingId>d0280f9e-afc1-47f3-9899c3a2cexample</reservedInstancesOfferingId> <instanceType>m1.xlarge</instanceType> <availabilityZone>us-east-1a</availabilityZone> <duration>25920000</duration> <fixedPrice>195.0</fixedPrice> <usagePrice>0.0</usagePrice> <productDescription>Linux/UNIX</productDescription> <instanceTenancy>dedicated</instanceTenancy> <currencyCode>USD</currencyCode> <offeringType>Heavy Utilization</offeringType> <recurringCharges> <item> <frequency>Hourly</frequency> <amount>0.2</amount> </item> </recurringCharges> <marketplace>true</marketplace> <pricingDetailsSet> <item>
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
<price>195.0</price> <count>1</count> </item> <item> <price>310.0</price> <count>1</count> </item> <item> <price>377.0</price> <count>1</count> </item> <item> <price>380.0</price> <count>1</count> </item> </pricingDetailsSet> </item> <item> <reservedInstancesOfferingId>649fd0c8-7846-46b8-8f84-a6400ex ample</reservedInstancesOfferingId> <instanceType>m1.large</instanceType> <availabilityZone>us-east-1a</availabilityZone> <duration>94608000</duration> <fixedPrice>1200.0</fixedPrice> <usagePrice>0.0</usagePrice> <productDescription>Linux/UNIX</productDescription> <instanceTenancy>default</instanceTenancy> <currencyCode>USD</currencyCode> <offeringType>Heavy Utilization</offeringType> <recurringCharges> <item> <frequency>Hourly</frequency> <amount>0.052</amount> </item> </recurringCharges> <marketplace>false</marketplace> <pricingDetailsSet/> </item> </reservedInstancesOfferingsSet> <nextToken>QUUVo/0S3X6nEBjSQZR/pRRlCPP/5Lrx79Wyxexample</nextToken> </DescribeReservedInstancesOfferingsResponse>
2.
From the list of available Reserved Instances in the previous example, select the marketplace offering and specify a limit price.
https://ec2.amazonaws.com/?Action=PurchaseReservedInstancesOffering &ReservedInstancesOfferingId=d0280f9e-afc1-47f3-9899-c3a2cexample &InstanceCount=1 &LimitPrice.Amount=200 &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
3.
You can run your Reserved Instance any time after your purchase is complete. To run your Reserved Instance, you launch it in the same way you launch an On-Demand instance. Make sure to specify the same criteria that you specified for your Reserved Instance. AWS will automatically charge you the lower hourly rate.
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
The Account Activity page will show all charges against your accountsuch as upfront and one-time fees and recurring charges. You can get both a summary of all your charges and a detailed list of your charges. The upfront charges from your purchase of third-party Reserved Instances in the Reserved Instance Marketplace will be listed under the AWS Marketplace Charges section, with the name of the seller displayed beside it. However, all recurring or usage charges for these Reserved Instances will be listed under the AWS Service Charges section.
You can view the charges online, and you can also download a PDF rendering of the charge information.
Amazon Elastic Compute Cloud User Guide Buying in the Reserved Instance Marketplace
The Detail section contains information about the Reserved Instancesuch as the Availability Zone, instance type, cost, and number of instances. It also includes the name of the seller of the Reserved Instances you purchased.
Related Topics
Amazon Machine Images (AMI) (p. 22) Amazon EC2 Instances (p. 88) Region and Availability Zone Concepts (p. 119)
Important
After launching an instance, you are billed hourly for running time. When you are finished with an instance, be sure to terminate it. For more information, see Terminating Instances (p. 388). 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 (p. 422).
Important
If you launch an instance that is not within the Free Usage Tier, you are billed after you launch the instance and charged for the time that the instance is running, even if it remains idle.
To launch an instance
1. 2. Sign in to the AWS Management Console and open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. From the navigation bar, select the region for the instance. This choice is important because some Amazon EC2 resources can be shared between regions, while others can't. Select the region that meets your needs. For more information, see Resource Locations (p. 560).
Amazon Elastic Compute Cloud User Guide Launching an Instance from an AMI
3.
From the Amazon EC2 console dashboard, click Launch Instance. The Create a New Instance page provides the following ways to launch an instance: The Classic Wizard provides more granular control and advanced settings for configuring your instance. The Quick Launch Wizard simplifies the process for you by automatically configuring many selections to get you started quickly with your instance. We recommend this wizard if you are just trying out Amazon EC2. For more information, see Getting Started with Amazon EC2 Linux Instances (p. 12). The AWS Marketplace is an online store where you can buy software that runs on AWS. You can launch your instance with just one click. For this procedure, use the Classic Wizard. Click Classic Wizard, and then click Continue. On the CHOOSE AN AMI page, the Quick Start tab displays a list of basic configurations called Amazon Machine Images (AMIs). An AMI contains all the information needed to create a new instance of a server. For example, an AMI might contain the software required to act as a web server (for example, Linux, Apache, and your website). To keep things simple, AWS marks the AMIs that are available in the Free Usage Tier with a star. As you are selecting an AMI, it's important to note whether the AMI is backed by an instance store or by Amazon EBS. Select the type of AMI that meets your needs. For more information, see Storage for the Root Device (p. 23). Choose the AMI to use and click Select. On the INSTANCE DETAILS page, change the following settings as necessary, and then click Continue. Number of Instances: Select the number of instances based on the selected AMI to launch. Instance Type: Select the size of the instance to launch. Larger instance types have more CPU and memory. To stay within the Free Usage Tier, choose Micro (t1.micro). Launch as an EBS-Optimized Instance: If the instance type supports this feature, select this check box to enable it. (Otherwise, this option is grayed out.) Additional charges apply. For more information, see EBS-Optimized Instances (p. 93).
API Version 2013-02-01 275
4.
5.
Amazon Elastic Compute Cloud User Guide Launching an Instance from an AMI
Availability Zone: Select the Availability Zone to use. We recommend that you choose No Preference.
6.
On the second INSTANCE DETAILS page, change the following advanced instance options as necessary, and then click Continue. Kernel ID: Select Use Default unless you want to use a specific kernel. For more information, see Kernels and RAM Disk FAQ. RAM Disk ID: Select Use Default unless you want to use a specific RAM disk. For more information, see Kernels and RAM Disk FAQ. Monitoring: Select this check box to enable detailed monitoring of your instance using Amazon CloudWatch. Additional charges apply. For more information, see Introduction to Amazon CloudWatch in the Amazon CloudWatch Developers Guide. User Data:You can specify user data to configure an instance during launch or to run a configuration script. base64 encoded: Select this check box if you want data to be base64 encoded. Termination Protection: Select this check box to prevent against accidental termination. For more information, see Enabling Termination Protection for an Instance (p. 390). Shutdown Behavior: Select whether the instance should stop or terminate when shut down. IAM Role: Select an AWS Identity and Access Management (IAM) role to associate with the instance. For more information, see Using IAM Roles with Amazon EC2 Instances (p. 450).
7.
8. 9.
On the third INSTANCE DETAILS page, you can click Edit to specify volumes to attach to the instance besides the volumes specified by the AMI (such as the root device volume), and then click Continue. For this example, it's fine to stick with the default Root volume. For more information about changing the block device mapping, see Updating the Block Device Mapping when Launching an Instance (p. 553). On the final INSTANCE DETAILS page, specify tags for the instance, and then click Continue. For more information about tags, see Tagging Your Amazon EC2 Resources (p. 566). On the CREATE KEY PAIR page, you can choose from any existing key pairs that you have created or create a new one. For this example, you create a key pair.
Important
Do not select the None option. If you launch an instance without a key pair, you can't connect to it. This option is used only when you are creating your own AMI and don't need to connect to the instance. a. b. Click Create a new Key Pair. Type a name for your key pair and then click Create & Download your Key Pair. You need the contents of the private key to connect to your instance after 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 need the key to connect to the instance.
c.
10. On the CONFIGURE FIREWALL page, the wizard automatically selects a security group 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. If you use an AMI on the Quick Start tab, the name and description for the
Amazon Elastic Compute Cloud User Guide Launching an Instance from an AMI
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 (that is, 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 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. 11. Click Continue to review your settings. When you're satisfied with your selections, click Launch to begin launching your instance.
2.
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 ec2-describe-instances command displays the launch status of the instance.
PROMPT> ec2-describe-instances i-1a2b3c4d RESERVATION r-1a2b3c4d 111122223333 default INSTANCE i-1a2b3c4d ami-1a2b3c4d ec2-67-202-51-223.compute-1.amazonaws.com ip-10-251-50-35.ec2.internal running gsg-keypair 0 m1.small YYYY-MMDDTHH:MM:SS+0000 us-east-1a aki-1a2b3c4d monitoring-disabled 184.73.10.99 10.254.170.223 ebs paravirtual xen ABCDE1234567890123 sg-1a2b3c4d default false BLOCKDEVICE /dev/sda1 vol-1a2b3c4d YYYY-MM-DDTHH:MM:SS.SSSZ true
3.
Amazon Elastic Compute Cloud User Guide Launching an Instance from an AMI
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; that is, the one that can be used to contact the instance from the Internet. The second DNS name is your instance's local DNS name, and can only be used to contact your instance 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.
API
To launch an instance
1. Use the RunInstances action. Construct the following request, where ami_id represents the latest version of an AMI.
https://ec2.amazonaws.com/ ?Action=RunInstances &ImageId=ami-1a2b3c4d &MaxCount=1 &MinCount=1 &KeyName=gsg-keypair &Placement.AvailabilityZone=us-east-1a &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Launching an Instance from an AMI
2.
Look for the instance ID in the instanceId element in the response 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 DescribeInstances action displays the launch status of the instance. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DescribeInstances &InstanceId=i-1a2b3c4d &AUTHPARAMS
3.
The following is an example response. In this response, ami_id represents the latest version of an AMI.
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <reservationId>r-1a2b3c4d</reservationId> <ownerId>111122223333</ownerId> <groupSet> <item> <groupId>default</groupId> </item> </groupSet> <instancesSet> <item> <instanceId>i-1a2b3c4d</instanceId> <imageId>ami-1a2b3c4d</imageId> <instanceState> <code>16</code> <name>running</name> </instanceState> <privateDnsName>ip-10-251-50-35.ec2.internal</privateDnsName> <dnsName>ec2-67-202-51-223.compute-1.amazonaws.com</dnsName> <keyName>gsg-keypair</keyName> <amiLaunchIndex>0</amiLaunchIndex> <instanceType>m1.small</instanceType> <launchTime>YYYY-MM-DDTHH:MM:SS.SSSZ</launchTime> <placement> <availabilityZone>us-east-1a</availabilityZone> <groupName/> <tenancy>default</tenancy> </placement> <monitoring> <state>disabled</state> </monitoring> </item> </instancesSet> </DescribeInstancesResponse>
Amazon Elastic Compute Cloud User Guide Creating and Launching an AMI from a Snapshot
When the instance state is running, as it is in the previous response, the instance has started booting.
Important
Registering a snapshot works only for Linux/UNIX AMIs; although you can register a snapshot to create a Windows AMI, the AMI isn't launchable.
Important
You must specify the correct architecture for your configuration. Select your architecture (i386 (32-bit) or x86_64 (64-bit)) from the Architecture list. You must manually specify the AKI to use from the Kernel ID list. If you do not specify it here, or if you select the default AKI, you are required to specify the AKI upon every launch. In addition, your instance may fail the health check because the default AKI is incompatible with the instance.
6. 7.
Click Yes, Create. After your AMI is registered, select it and click Launch. This launches your new AMI from your snapshot.
Amazon Elastic Compute Cloud User Guide Creating and Launching an AMI from a Snapshot
The AMI now appears in the list of AMIs that you own.You can view that list in the AWS Management Console, or by using the following command: ec2-describe-images -o self. 2. Launch an instance of the AMI. The resulting instance has a root device volume created from the snapshot.
API
1. Issue the following Query request to register an image. The example specifies the root device as /dev/sda1, and maps it to the snap-1a2b3c4d snapshot. The resulting root device volume is the same size as the snapshot, and it is automatically be deleted on instance termination. You can set DeleteOnTermination to false if you would rather have the volume persist.
https://ec2.amazonaws.com/ ?Action=RegisterImage &Name=MyImage &KernelId=aki-1a2b3c4d &RamdiskId=ari-1a2b3c4d &RootDeviceName=/dev/sda1 &BlockDeviceMapping.1.DeviceName=/dev/sda1 &BlockDeviceMapping.1.Ebs.SnapshotId=snap-1a2b3c4d &AUTHPARAMS
For information about the auth parameters, see Common Query Parameters in the Amazon Elastic Compute Cloud API Reference. The following is an example response.
<RegisterImageResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <imageId>ami-1a2b3c4d</imageId> </RegisterImageResponse>
The AMI now appears in the list of AMIs that you own. You can view that list by using DescribeImages with Owner=self. 2. Launch an instance of the AMI. The resulting instance has a root device volume created from the snapshot.
Amazon Elastic Compute Cloud User Guide Connecting to Amazon EC2 Instances
Note
In Amazon EC2, all key pairs, whether created or imported, are specific to the region that they are created in or imported to. Make sure your EC2-Classic endpoint is correctly set before creating or importing the key pair. Amazon EC2 doesn't store a copy of the private key for either option. Amazon EC2 only stores the public key, and associates it with a friendly name that you specify for the key pair.
API Version 2013-02-01 282
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
Note
If you are using PuTTY in Windows, you must convert the private key to PuTTY's format. For more information about using PuTTy with Amazon EC2, see Connecting to Linux/UNIX Instances from Windows Using PuTTY (p. 304).
2.
3.
Click Key Pairs in the navigation pane to display the list of key pairs associated with your account in the current region.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
4.
5.
Enter a name for the new key pair in the Key Pair Name field of the Create Key Pair dialog box and click Create.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
6.
The private key file will automatically be downloaded by your browser. The file name will be the key pair name with the .pem extension. In this example, the private key file will be gsg-keypair.pem. Save the private key file in a safe place. You will need it to access any instances that you launch with this key pair.
Amazon EC2 returns the contents of the private key, similar to this one.
KEYPAIR gsg-keypair 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f ---- BEGIN RSA PRIVATE KEY ---MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6 b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ 21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4 nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE= -----END RSA PRIVATE KEY-----
2.
Create a file named gsg-keypair.pem and paste the entire key generated in step 1, including the following lines.
"---- BEGIN RSA PRIVATE KEY ----" "-----END RSA PRIVATE KEY-----"
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
3.
Confirm that the file contents looks similar to the following and save the file. You can save the file in any directory, but if you do not put it in your current directory, you must specify the full path when using commands that require the key pair.
---- BEGIN RSA PRIVATE KEY ---MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6 b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ 21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4 nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE= -----END RSA PRIVATE KEY-----
4.
If you're using OpenSSH (or another SSH client), you should set the permissions of the private key file so it is only readable by you. On Linux and UNIX, enter the information in the following example.
$ chmod 400 gsg-keypair.pem ; ls -l gsg-keypair.pem
5.
After the public key file is imported, verify that the key pair is valid as shown in Verifying Your Key Pair (p. 292).
API
Use the CreateKeyPair action.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f </keyFingerprint> <keyMaterial>---- BEGIN RSA PRIVATE KEY ---MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6 b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ 21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4 nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE= -----END RSA PRIVATE KEY-----</keyMaterial> </CreateKeyPairResponse>
2.
Create a file named gsg-keypair.pem and paste the entire key generated in step 1, including the following lines.
"---- BEGIN RSA PRIVATE KEY ----" "-----END RSA PRIVATE KEY-----"
3.
Confirm that the file contents looks similar to the following and save the file. You can save the file in any directory, but if you do not put it in your current directory, you must specify the full path when using commands that require the key pair.
---- BEGIN RSA PRIVATE KEY ---MIICiTCCAfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC VVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6 b24xFDASBgNVBAsTC0lBTSBDb25zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAd BgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhcNMTEwNDI1MjA0NTIxWhcN MTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYD VQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb25z b2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFt YXpvbi5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMaK0dn+a4GmWIWJ 21uUSfwfEvySWtC2XADZ4nB+BLYgVIk60CpiwsZ3G93vUEIO3IyNoH/f0wYK8m9T rDHudUZg3qX4waLG5M43q7Wgc/MbQITxOUSQv7c7ugFFDzQGBzZswY6786m86gpE Ibb3OhjZnzcvQAaRHhdlQWIMm2nrAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAtCu4 nUhVVxYUntneD9+h8Mg9q6q+auNKyExzyLwaxlAoo7TJHidbtS4J5iNmZgXL0Fkb FFBjvSfpJIlJ00zbhNYS5f6GuoEDmFJl0ZxBHjJnyp378OD8uTs7fLvjx79LjSTb NYiytVbZPQUQ5Yaxu2jXnimvw3rrszlaEXAMPLE= -----END RSA PRIVATE KEY-----
4.
If you're using OpenSSH (or another SSH client), you should set the permissions of this file so it is readable only by you. On Linux and UNIX, enter the information in the following example.
$ chmod 400 gsg-keypair.pem ; ls -l gsg-keypair.pem
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
5.
After the public key file is imported, verify that the key pair is valid as shown in Verifying Your Key Pair (p. 292).
2.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
3.
Click Key Pairs in the navigation pane to display the list of key pairs associated with your account in the current region.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
4.
5.
In the Import Keypair dialog, select the public key file saved above, enter a name for the key pair in the Keypair Name field, and click Yes, Import.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
6.
After the public key file is imported, verify that the key pair is valid as shown in Verifying Your Key Pair (p. 292).
2.
After the public key file is imported, verify that the key pair is valid as shown in Verifying Your Key Pair (p. 292).
API
To import the public key
1. Use the ImportKeyPair action to import the public key file to Amazon EC2. The following Query example names the key pair gsg-keypair. You must base64 encode the public key material before sending it to Amazon EC2.
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
https://ec2.amazonaws.com/?Action=ImportKeyPair &KeyName=gsg-keypair &PublicKeyMaterial=LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tDQpNSUlDZHp DQ0FlQ2dBd0lCQWdJR0FQalRyR3pQ TUEwR0NTcUdTSWIzRFFFQkJRVUFNRk14Q3pBSkJnTlZCQVlUDQpBbFZUTVJNd0VRWURWUVFLRXdw QmJXRjZiMjR1WTI5dE1Rd3dDZ1lEVlFRTEV3TkJWMU14SVRBZkJnTlZCQU1UDQpHRUZYVXlCTWFX MXBkR1ZrTFVGemMzVnlZVzVqWlNCRFFUQWVGdzB3T1RBM016RXlNVFEzTXpWYUZ3MHhNREEzDQpN ekV5TVRRM016VmFNRkl4Q3pBSkJnTlZCQVlUQWxWVE1STXdFUVlEVlFRS0V3cEJiV0Y2YjI0dVky OXRNUmN3DQpGUVlEVlFRTEV3NUJWMU10UkdWMlpXeHZjR1Z5Y3pFVk1CTUdBMVVFQXhNTWJUSnVi RGhxZW00MWVHUjFNSUdmDQpNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0R05BRENCaVFLQmdRQ1dOazBo QytrcExBRnp2YkFQc3U1TDU5bFMwUnI0DQprZEpaM0RFak1pL0IwV2ZDSzhpS2hWYWt1WitHSnJt NDdMUHZCaFVKWk9IeHVUU0VXakFDNmlybDJzKzlSWXVjDQpFZXg0TjI4ZlpCZGpORlAzdEgwZ2Nu WjdIbXZ4aFBrTEtoRTdpZmViNmNGWUhRdHpHRnRPQ0ZQTmdUSE92VDE5DQoyR3lZb1VyU3BDVGFC UUlEQVFBQm8xY3dWVEFPQmdOVkhROEJBZjhFQkFNQ0JhQXdGZ1lEVlIwbEFRSC9CQXd3DQpDZ1lJ S3dZQkJRVUhBd0l3REFZRFZSMFRBUUgvQkFJd0FEQWRCZ05WSFE0RUZnUVU1RVNuTUZZUzdyTDNX TUdLDQpqejMxVXZ5TThnMHdEUVlKS29aSWh2Y05BUUVGQlFBRGdZRUFnWjdDZ1lJWHR1WFM1NHVq bU5jOTR0NWRNc3krDQpCM0Z3WVVNdUd4WUI2eGQvSUVWMTFLRVEyZ0hpZUdMU21jUWg4c2JXTTdt KzcrYm9UNmc2U2hLbU1jblkzWkRTDQpWRVFZZ25qcEt1aEZRd2pmaVpTUEc1UG5SVENhdkVqS3lT TUpDVGxpdTdTTjMrR2J3cFU5Uzg3K21GM2tsMGRmDQpZNlIrbEl5SWcrU3ROOTg9DQotLS0tLUVO RCBDRVJUSUZJQ0FURS0tLS0tEXAMPLE &AuthParams
The response includes the MD5 public key fingerprint as specified in section 4 of RFC4716.
<ImportKeyPairResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId> <keyName>gsg-keypair</keyName> <keyFingerprint> 00:00:00: 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 </keyFingerprint> </ImportKeyPairResponse>
2.
After the public key file is imported, verify that the key pair is valid as shown in Verifying Your Key Pair (p. 292).
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
Amazon Elastic Compute Cloud User Guide Getting an SSH Key Pair
4. Verify that the key pair that was created or imported exists in the list of key pairs associated with your account in the current region.
Amazon Elastic Compute Cloud User Guide Authorizing Network Access to Your Instances
Command Line Tools Use the ec2-describe-keypairs command to list the key pairs currently associated with your account. API Use the DescribeKeyPairs action to list the key pairs currently associated with your account.
2.
Launch a New Instance To verify that the key pair works correctly, launch a new Linux instance that uses the new key pair, and then connect to that instance. For more information about launching Linux instances, see Launch an Amazon EC2 Instance. In step 6 of the procedure, under Choose a Key Pair, select the Select Existing option, and select the key pair you created from the drop-down list. After the instance is running, connect to it as shown in Connect to Your Instance. In step 8 of the procedure, enter the path and file name of the private key file you saved. In this example, the private key file name is gsg-keypair.pem. If you can successfully connect to the instance, the key pair is working correctly.
Amazon Elastic Compute Cloud User Guide Authorizing Network Access to Your Instances
3. 4.
5. 6. 7.
In the Source field, specify your local system's public IP address in CIDR notation. For example, if your IP address is 203.0.113.0, enter 203.0.113.0/32. Click Add Rule. An asterisk appears on the Inbound tab, indicating that the rule hasn't been applied. When you're finished adding rules, click Apply Rule Changes. The new rules are applied to all instances that are associated with the security group.
To add a rule to a security group for RDP access for Windows instances
1. 2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. Click Instances in the Navigation pane. Select your instance and look at the Description tab; the Security Groups field lists the security groups that are associated with the instance. Click the view rules link to display a list of the rules that are in effect for the instance. Click Security Groups in the Navigation pane. Select one of the EC2 security groups associated with your instance. From the Create a new rule list on the Inbound tab, select RDP.
3. 4.
Amazon Elastic Compute Cloud User Guide Authorizing Network Access to Your Instances
5. 6. 7.
In the Source field, specify your local system's public IP address in CIDR notation. For example, if your IP address is 203.0.113.0, enter 203.0.113.0/32. Click Add Rule. An asterisk appears on the Inbound tab, indicating that the rule hasn't been applied. When you're finished adding rules, click Apply Rule Changes. The new rules are applied to all instances that are associated with the security group.
API
Use the AuthorizeSecurityGroupIngress action.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances Using SSH
2.
This second request gives your local system the ability to use Remote Desktop (port 3389) to connect to any instance in the "default" security group.
https://ec2.amazonaws.com/ ?Action=AuthorizeSecurityGroupIngress &GroupName=default &IpPermissions.1.IpProtocol=tcp &IpPermissions.1.FromPort=3389 &IpPermissions.1.ToPort=3389 &IpPermissions.1.IpRanges.1.CidrIp=your-local-system's-public-ip-address/32 &AUTHPARAMS
3.
This third request allows all port 80 traffic into all instances in the "default" security group.
https://ec2.amazonaws.com/ ?Action=AuthorizeSecurityGroupIngress &GroupName=default &IpPermissions.1.IpProtocol=tcp &IpPermissions.1.FromPort=80 &IpPermissions.1.ToPort=80 &IpPermissions.1.IpRanges.1.CidrIp=0.0.0.0/0 &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances Using SSH
Note
On a Windows or Mac client, you must run your Web browser with administrator credentials. For Linux, additional steps may be required if you are not logged in as root. 1. Install Java (see http://java.com/en/download/help/index_installing.xml) 2. Enable Java in your web browser (see http://java.com/en/download/help/enable_browser.xml)
5.
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. 6. 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. Click Save key location, click Stored in browser cache to store the key location in your browser cache so the key location is detected in subsequent browser sessions, until your clear your browsers cache. Click Launch SSH Client.
9.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances Using SSH
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 will ask you to confirm setup for your home directory and other settings. 14. Confirm settings for MindTerm setup. A screen opens and you are connected to your instance.
Prerequisites
Enable SSH trafficOpen SSH port on the instance.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances Using SSH
Before you try to connect, ensure that your Amazon EC2 instance accepts incoming SSH traffic (usually on port 22). For more information, see Authorizing Network Access to Your Instances (p. 295). Most Linux and UNIX computers include an SSH client by default. You can check for an SSH client by typing ssh at the command line. If your computer doesn't recognize the command, the OpenSSH project provides a free implementation of the full suite of SSH tools. For more information, go to http://www.openssh.org. Private keyGet the path to your private key You'll need the fully qualified path of the private key file associated with your instance. For more information on key pairs, see Getting an SSH Key Pair (p. 282).
... ec2: -----BEGIN SSH HOST KEY FINGERPRINTS----ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_key.pub ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_rsa_key.pub ec2: 1024 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_dsa_key.pub ec2: -----END SSH HOST KEY FINGERPRINTS----...
2. 3.
Note the fingerprints so that you can compare them to the fingerprints of the instance. In a command line shell, change directories to the location of the private key file that you created when you launched the instance. Use the chmod command to make sure your private key file isn't publicly viewable. For example, if your private key file were My_Keypair.pem, you would enter:
chmod 400 My_Keypair.pem
4. 5. 6. 7.
In the Navigation pane, click Instances. Right-click your instance, and then click Connect. Click Connect using a standalone SSH client. AWS automatically detects the public DNS address of your instance and the key pair name you launched the instance with. Copy the example command provided in the Amazon EC2 console if you launched an Amazon Linux instance. If you used a different Amazon Machine Image (AMI) for your Linux/UNIX instance, you need to log in as the default user for the AMI. For an Ubuntu instance, the default user name is ubuntu. Some AMIs allow you to log in as root so you will need to change the user name from ec2-user to the appropriate user name.
ssh -i <your key a name>.pem ec2-user@ec2-184-72-204-112.compute-1.amazon aws.com
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances Using SSH
Important
If you've launched a public AMI, verify that the fingerprint matches the fingerprint from the output of the ec2-get-console-output command. If it doesn't, someone might be attempting a "man-in-the-middle" attack. 8. Enter yes. You'll see a response like the following.
Warning: Permanently added 'ec2-184-72-204-112.compute-1.amazonaws.com' (RSA) to the list of known hosts.
Prerequisites
Enable SSH trafficOpen the instance's SSH port
API Version 2013-02-01 302
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances Using SSH
Before you try to connect, ensure that your Amazon EC2 instance accepts incoming SSH traffic (usually on port 22). For more information, see Authorizing Network Access to Your Instances (p. 295). SCP clientInstall an SCP client Most Linux and UNIX computers include an SCP client by default. If yours doesn't, the OpenSSH project provides a free implementation of the full suite of SSH tools, including an SCP client. For more information, go to http://www.openssh.org. Instance IDGet the ID of your Amazon EC2 instance Retrieve the Instance ID of the Amazon EC2 instance you want to access. The Instance IDs for all of your instances are available in the Amazon EC2 console or with the ec2-describe-instances command. Instance's public DNSGet the public DNS of your Amazon EC2 instance Retrieve the public DNS of the Amazon EC2 instance you want to access. You can find the public DNS for your instance using the Amazon EC2 console or with the ec2-describe-instances command. Private keyGet the path to your private key You'll need the fully qualified path of the private key file associated with your instance. For more information on key pairs, see Getting an SSH Key Pair (p. 282).
The following procedure steps you through using SCP to transfer a file. If you've already connected to the instance with SSH and have verified its fingerprints, you can start with the step that contains the SCP command (step 4).
... ec2: -----BEGIN SSH HOST KEY FINGERPRINTS----ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_key.pub ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_rsa_key.pub ec2: 1024 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_dsa_key.pub ec2: -----END SSH HOST KEY FINGERPRINTS----...
Note the fingerprints so that you can compare them to the fingerprints of the instance. 2. 3. In a command line shell, change directories to the location of the private key file that you created when you launched the instance. Use the chmod command to make sure your private key file isn't publicly viewable. For example, if your file were My_Keypair.pem, you would enter:
chmod 400 My_Keypair.pem
4.
Transfer a file to your instance using the instance's public DNS name (available through the AWS Management Console or the ec2-describe-instances command). For example, if the key file is My_Keypair.pem, the file to transfer is samplefile.txt, and the instance's DNS name is ec2-184-72-204-112.compute-1.amazonaws.com, use the following command to copy the file to the ec2-user home directory.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances from Windows Using PuTTY scp -i My_Keypair.pem samplefile.txt ec2-user@ec2-184-72-204-112.compute1.amazonaws.com:~
Note
Some AMIs let you log in as root, but some require that you log in with the username ec2-user. For log in information for your chosen AMI, contact your AMI provider directly or go to Amazon Machine Images(AMIs) page, then locate and click your AMI on the list. You'll see a response like the following.
The authenticity of host 'ec2-184-72-204-112.compute-1.amazonaws.com (10.254.142.33)' can't be established. RSA key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00. Are you sure you want to continue connecting (yes/no)? yes
Important
If you've launched a public AMI, verify that the fingerprint matches the fingerprint from the output of the ec2-get-console-output command. If it doesn't, someone might be attempting a "man-in-the-middle" attack. 5. Enter yes. You'll see a response like the following.
Warning: Permanently added 'ec2-184-72-204-112.compute-1.amazonaws.com' (RSA) to the list of known hosts. Sending file modes: C0644 20 samplefile.txt Sink: C0644 20 samplefile.txt samplefile.txt 100% 20 0.0KB/s 00:00
To transfer files in the other direction, i.e., from your Amazon EC2 instance to your local computer, simply reverse the order of the host parameters. For example, to transfer the samplefile.txt file from your Amazon EC2 instance back to the home directory on your local computer as samplefile2.txt, use the following command on your local computer.
scp -i My_Keypair.pem ec2-user@ec2-184-72-204-112.compute-1.amazon aws.com:~/samplefile.txt ~/samplefile2.txt
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances from Windows Using PuTTY
To connect to your Linux/UNIX instance from a Windows computer, use an SSH client. The following instructions explain how to use PuTTY, a free SSH client for Windows computers.
Prerequisites
Enable SSH trafficOpen the instance's SSH port Before you try to connect, ensure that your Amazon EC2 instance's security group accepts incoming SSH traffic on port 22. For more information, see Authorizing Network Access to Your Instances (p. 295). Instance IDGet the ID of your Amazon EC2 instance Retrieve the Instance ID of the Amazon EC2 instance you want to access. The Instance IDs for all of your instances are available in the Amazon EC2 console or with the ec2-describe-instances command. Instance's public DNSGet the public DNS of your Amazon EC2 instance Retrieve the public DNS of the Amazon EC2 instance you want to access. You can find the public DNS for your instance using the Amazon EC2 console or with the ec2-describe-instances command. Private keyGet the path to your private key You'll need the fully qualified path of the private key file associated with your instance. For more information on key pairs, see Getting an SSH Key Pair (p. 282).
Getting PuTTY
To download and install PuTTY
Go to http://www.chiark.greenend.org.uk/~sgtatham/putty/ and follow the instructions there.
Other tools in the PuTTY suite are PuTTYgen, a key generation program, and pscp, a secure copy command line tool. The different PuTTY tools are separate applications. You can install them separately or install the entire suite with a simple Windows installer. The following instructions assume you've installed the entire suite and can access all the components from the Windows Start menu.
3.
Select your .pem key file and click Open. PuTTYgen displays the following message.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances from Windows Using PuTTY
When you click OK, PuTTYgen displays a dialog box with information about the key you loaded, such as the public key and the fingerprint. The keys that Amazon EC2 generates are 1024-bit SSH-2 RSA keys. 4. Click Save private key to save the key in PuTTY's format. PuTTYgen asks if you want to save the key without a passphrase.
5.
Click Yes.
Note
A passphrase on a private key is an extra layer of protection, so even if your private key is discovered, it will not be usable without the passphrase. The downside to using a passphrase is that it makes automation harder because human intervention is needed to log on to an instance, or copy files to an instance. For this exercise, we're not using a passphrase. 6. Use the same name for the key that you used for the key pair (for example, gsg-keypair). PuTTY automatically adds the .ppk file extension.
Your private key is now in the correct format for use with PuTTY. You can now connect to your instance using PuTTY's SSH client.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances from Windows Using PuTTY C:\> ec2-get-console-output instance_id
... ec2: -----BEGIN SSH HOST KEY FINGERPRINTS----ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_key.pub ec2: 2048 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_rsa_key.pub ec2: 1024 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 /etc/ssh/ssh_host_dsa_key.pub ec2: -----END SSH HOST KEY FINGERPRINTS----...
Note the fingerprints so that you can compare them to the fingerprints of the instance. 2. 3. Start PuTTY (from the Start menu, click All Programs > PuTTY > PuTTY). In the Host Name field, enter the public DNS name of your instance (available through the Amazon EC2 console or the ec2-describe-instances command).
4. 5. 6.
Under Connection type, select SSH and ensure that the Port is set to 22. In the Category tree, under Connection, expand the SSH node, and then select Auth. Click Browse... and select the PuTTY private key file you generated in the preceding section.
Amazon Elastic Compute Cloud User Guide Connecting to Linux/UNIX Instances from Windows Using PuTTY
7.
8.
If you will be opening this same session later, you may want to save it for future use. To save the session information, select Session in the Category tree, enter a name for the session in Saved Sessions, and click Save. This step is optional. Click Open. If this is the first time you have connected to this instance, a security alert dialog box will be displayed asking if you trust the host you are connecting to,
Important
If you've launched a public AMI, verify that the fingerprint in the security alert matches the fingerprint from the output of the ec2-get-console-output command. If it doesn't, someone might be attempting a "man-in-the-middle" attack. 9. If the security alert dialog box is displayed, click Yes. 10. In the SSH session window, log in with the appropriate username. In most cases, the username will be ec2-user. No password is required because the authentication is provided by the selected public/private key pair.
Note
Some AMIs let you log in as root, but some require you to log in with the username ec2-user. For log in information for your chosen AMI, contact your AMI provider directly or go to Amazon Machine Images(AMIs) page, then locate and click your AMI on the list.
Note
If you specified a passphrase when you converted your private key to PuTTY's format, you must provide that passphrase when you log in to the instance.
If you prefer a graphical user interface (GUI), you can use an open source GUI tool named WinSCP. For more information, go to the WinSCP website.
Prerequisites
Enable RDP trafficOpen the instance's RDP port Before you try to connect, ensure that your Amazon EC2 instance accepts incoming RDP traffic (usually on port 3389). For more information, see Authorizing Network Access to Your Instances (p. 295). RDP clientInstall an RDP client Windows computers include an RDP client by default.You can check for an RDP client by typing mstsc at a Command Prompt window. If your computer doesn't recognize this command, go to the Microsoft Windows home page and search for the download for Remote Desktop Connection. For Mac OS X, you can use Microsoft's Remote Desktop Client. For Linux/UNIX, you can use rdesktop. Instance IDGet the ID of your Amazon EC2 instance Retrieve the Instance ID of the Amazon EC2 instance you want to access. The Instance IDs for all of your instances are available in the Amazon EC2 console or with the ec2-describe-instances command. Private keyGet the path to your private key You'll need the fully qualified path of the private key file associated with your instance. For more information on key pairs, see Getting an SSH Key Pair (p. 282).
A thumbprint is a series of hexadecimal numbers enclosed in a <THUMBPRINT> tag. For example, a thumbprint might look like <THUMBPRINT>2C81502A74D7B112DF801E460A16F53DFEXAMPLE</THUMBPRINT>. Note the displayed thumbprint; we'll compare this thumbprint to the thumbprint of the instance as we connect to it.
2.
Retrieve the initial administrator password: a. b. Go to the Amazon EC2 console and locate the instance on the Instances page. Right-click the instance and select Get Windows Password (it might take a few minutes after the instance is launched before the password is available). The Retrieve Default Windows Administrator Password dialog box is displayed.
c. d. e.
Click Browse and navigate to the private key file you created when you launched the instance. Select the file and click OK to paste the contents of the private key file into the Private Key field. Click Decrypt Password. The console returns the default administrator password for the instance. Save the password. You'll need it to connect to the instance.
3.
Connect to the instance using Remote Desktop: a. b. c. Go to the Amazon EC2 console and locate the instance on the Instances page. Right-click the instance and select Connect. Click Download shortcut file. Your browser prompts you to either open or save the .rdp file. Either option is fine. When you have finished, click Close. Launch the shortcut file. Log in to the instance as prompted, using Administrator as the user name and the default administrator password you saved in the previous step. The Amazon EC2 instance returns a security alert. To verify the instance, click View Certificate. The Certificate page appears. Click the Details tab. The Details page appears. Select Thumbprint and verify its value against the value you wrote down previously.
d. e.
f. g. h.
Important
If you've launched a public AMI, verify that the thumbprint matches a thumbprint from the instance's RDP certificate. If it doesn't, someone might be attempting a "man-in-the-middle" attack. i. If the thumbprints match, click OK and then Yes. The Remote Desktop Connection client connects to the instance.
Note
If you have disabled the local Administrator account, you cannot reset the password using this method.
Prerequisites
A Microsoft Windows Server 2003, Microsoft Windows Server 2008 or Microsoft Windows Server 2012 instance whose password needs to be reset. EC2ConfigService installed on the instance whose password is to be reset (default on all Amazon Windows AMIs): c:\program files\amazon\ec2configservice\settings\config.xml c:\program files\amazon\ec2configservice\docs\ec2configservice.doc A running Windows Server 2003 instance in the same availability zone as the instance that needs the password reset that you can log into. Windows Server 2003 instances are preferred because they use an older boot loader that will not try to modify the attached volumes boot files.
3. 4.
Right-click the instance on which you want to reset the password, and then click Stop. In the Stop Instances dialog box, click Yes, Stop.
5.
6. 7. 8.
In the EBS Volumes pane, right-click the boot volume of the instance whose password you want to reset, and then click Detach Volume. After the volumes status changes to available, right-click the volume and click Attach Volume. In the Attach Volume dialog box, in the Instances drop-down list, select your Windows Server 2003 instance.
9.
In the Device box, type xvdf (if it isnt already there), and then click Yes, Attach.
10. Log in to the Windows Server 2003 instance on which you just attached the volume. 11. On the volume you attached, navigate to the \Program Files\Amazon\Ec2ConfigService\Settings\config.xml file, and open it using Notepad.exe. 12. At the top of the file, under <Plugin>, <Name>Ec2SetPassword</Name>, change <State>Disabled</State> to <State>Enabled</State>, and then save the file.
13. In the EC2 console, in the Navigation pane, under ELASTIC BLOCK STORE, click Volumes.
14. In the EBS Volumes pane, right-click the boot volume of the instance whose password you want to reset, and then click Detach Volume. 15. After the volumes status changes to available, right-click the volume and click Attach Volume.
16. In the Attach Volume dialog box, in the Instances drop-down list, select the Windows Server instance that you originally removed this volume from.
17. In the Device box, type /dev/sda1, and then click Yes, Attach. 18. In the Navigation pane, click Instances, right-click the instance, and then click Start. 19. In the Start Instances dialog box, click Yes, Start.
Note
The instance will get a new IP address and DNS name. 20. Update your Remote Desktop Protocol connection with the new DNS name.
Note
In this example, the IP address and DNS name changed from ec2-184-72-161-218.compute-1.amazonaws.com to ec2-107-21-75-21.compute-1.amazonaws.com.
21. At a command prompt, type telnet <the new DNS name> 3389, and then press Enter. This tests whether the instance is accessible. 22. In the EC2 console, in the Navigation pane, under Instances, click Instances. 23. Right-click the instance on which you want to reset the password, and then click Get Windows Password. 24. In the Retrieve Default Windows Administrator Password dialog box, click Browse, and then select the appropriate .pem (certificate) file.
Amazon Elastic Compute Cloud User Guide Importing and Exporting Instances
25. Click Decrypt Password, and then copy the decrypted password and log in to the instance.
If you are importing a VMware vSphere VM, you can also use the Amazon EC2 VM Import Connector for VMware (Connector), a plug-in that integrates with VMware vSphere Client, to perform the task. Whether you use the command line tools or the API, or the Connector, you will follow the same general process for importing VMs or volumes to Amazon EC2. You need to complete these tasks, which are all discussed in this section: 1. Prepare the virtual machine for import to Amazon EC2. For more information, go to Before You Get Started (p. 320) 2. Export the virtual machine from the external environment. Exporting from Citrix (p. 336) Exporting from Microsoft Hyper-V (p. 339) Exporting from VMware (p. 340) 3. Import the virtual machine to Amazon EC2. For information about using the command line tools to import your VM, see Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2 (p. 335). For information about using the Connector, see Using the Amazon EC2 VM Import Connector to Import Your Virtual Machine to Amazon EC2 (p. 321). 4. Upload the instance to Amazon EC2. 5. Launch the instance in Amazon EC2. The following figure shows the process of importing a VM or volume.
Client
The software you need on your Citrix Xen Center computer to access and manage Microsoft Hyper-V Manager your virtualization platform VMware vSphere Client environment The management platform for the Citrix XenServer virtualization environment Microsoft Hyper-V VMware vCenter Server The virtual appliance, a plug-in to the management platform of the virtualization Server, that enables the import of virtual machines into Amazon EC2 using the Client interface Citrix Xen (not applicable) Microsoft Hyper-V (not applicable) VMware vCenterAmazon EC2 VM Import Connector for VMware vCenter (Connector)
Server
Multiple network interfaces are not currently supported. When converted and imported, your instance will have a single virtual NIC using DHCP for address assignment. For vCenter 4.0 and vSphere 4.0 users, remove any attached CD-ROM images or ISOs from the virtual machine.
Important
If you are importing a virtual machine from Citrix Xen, you must uninstall the Citrix Tools for Virtual Machines from the VM. If you don't uninstall the tools, your import will fail. For more information, see Exporting from Citrix (p. 336). Enable Remote Desktop (RDP) for remote access. Make sure your host firewall (Windows firewall), if configured, allows access to RDP. Otherwise, you will not be able to access your instance after the conversion is complete. Make sure all user accounts use secure passwords. This includes the administrator account.
Note
All accounts must have passwords. Otherwise, the import might fail.
Disable any antivirus or intrusion detection software on your virtual machine. These services can be re-enabled after the import process is complete. Disconnect any CD-ROM drives (virtual or physical).
Using the Amazon EC2 VM Import Connector to Import Your Virtual Machine to Amazon EC2
Topics Before You Install the Connector (p. 321) Installing the Connector for VMware vCenter (p. 323) Configuring the Connector for VMware vCenter (p. 327) Using the Connector for VMware vCenter (p. 332) Uninstalling the Connector for VMware vCenter (p. 334) You can use the Amazon EC2 VM Import Connector virtual appliance (vApp), a plug-in for VMware vCenter, to import virtual machines from your VMware vSphere infrastructure to Amazon EC2. The Connector is a virtual appliance that works with VMware vCenter Server only. It provides an easy-to-use interface, enhancing your existing management tools to work with the Amazon EC2 VM Import Connector.
Note
You cannot use the Connector to import Citrix Xen or Microsoft Hyper-V virtual machines to Amazon EC2. Instead, use the command line tools to import your Citrix and Hyper-V virtual machines to Amazon EC2. You can also choose to use the command line tools to import your VMware VMs. For more information, see Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2 (p. 335). Using the Connector simplifies the process of importing your VMware VMs: You prepare the virtual machine for import to Amazon EC2, and then you import it to EC2. The following figure shows the process of importing VMware VMs using the Connector and without using the Connector.
VMware infrastructure vSphere 4.0, 4.1, or 5.0 vCenter 4.0, 4.1, or 5.0 Amazon EC2 VM Import Connector vApp 256MB RAM Minimum 250GB of disk space
Note
Although the Connector virtual appliance is small, it temporarily stores the VM images that you import to Amazon EC2. The data store must be large enough to accommodate these images, plus the Connector. We recommend a data store size of 250GB or larger. To estimate the disk space you need, multiply the maximum number of parallel import tasks you want to run with the Connector by the average size you expect your VMs to be, then add about 10GB for the virtual appliance. For example, if you project that you will run a maximum of 5 imported VMs averaging 75GB in size, then you'll need about 385GB of disk space.
Internet access Outbound Internet access, either direct or via a proxy, from the Connector appliance on TCP port 443 (SSL) to Amazon EC2 and Amazon S3.
Note
If you are adding a firewall rule to allow this access and want to further restrict this access to Amazon EC2 and Amazon S3, you can add the hosts at the published endpoints as the destinations on TCP port 443. For more information about the current endpoints go to Regions and Endpoints. DHCP server A static IP address or an IP reservation via DHCP for the virtual appliance
Note
You must set up a static DHCP lease or configure a static IP before you begin the configuration process.
Connector local network access Inbound TCP 443 (SSL) from vCenter Server and vSphere Client Inbound TCP 80 (HTTP) from the LAN for Connector Web Console Administrative rights To VMware vSphere and VMware vCenter for installation. For information on how to allow a user without administrative rights to use the Connector to import VMs to Amazon EC2, see To grant permission to non-administrative users to import VMs to Amazon EC2 (p. 329). AWS access credentials The Connector stores AWS credentials for each VMware vCenter user. In this way, multiple users with separate AWS credentials can use the same Connector. Alternatively, you can use the same AWS account and credentials with more than one user. Each VMware vSphere user will need to fill out the information in the Enter AWS Credentials dialog box the first time he or she uses the Connector. For information on how to get your AWS credentials, see How to Get Your Access Key ID and Secret Access Key (p. 444).
API Version 2013-02-01 322
Your AWS account must be subscribed to Amazon EC2 before you start the import process.
Note
The Connector virtual appliance stores your AWS credentials. To protect these credentials from unauthorized use, grant access to the virtual appliance's console and configuration only to administrators.
4.
A series of Deploy OVF Template screens walks you through the deployment process. Confirm that the Deploy OVF Template screen is displaying correct information about the VM Import Connector, and click Next.
5.
Specify the name and location of the Connector or accept the default, then click Next.
6.
Select the host or cluster in which you want the Connector to run, then click Next.
7.
Select the data store where the Connector will be stored, then click Next.
Note
Although the Connector virtual appliance is small, it temporarily stores the images of the virtual machines that import to Amazon EC2. Therefore, the data store must be large enough to accommodate these images, as well as the Connector. We recommend a data store size of 250GB or larger.
8.
9.
Confirm the details you selected and click Finish. The Connector virtual appliance will now install.
When the Connector is running, you will find its IP address and password displayed in the vCenter Console. Your Connector information will be similar to the following example:
2.
When you are logged in, the browser displays Connector status information. Note that the Connector is not yet registered with the vCenter Server. Confirm that everything else in the Connector Status list has a status of OK.
3.
If the version of the Connector that you are registering is not an upgrade, click Register Now. If you are upgrading the Connector, you must take the next two steps before registering. Confirm that all import tasks are complete. Deregister the old Connector from vCenter. To do this, go to the vCenter tab and click Deregister.
4.
The vCenter Connector Registration page appears. Provide the IP address of the vCenter with which you want to register the Connector. The user name and password you use must have administrative rights. Click Register Connector with vCenter.
Note
If an error occurs, check that the VMware vCenter IP address or name that you provided is correct. Also, confirm that the Connector virtual appliance has network access to TCP port 443 on your vCenter Server. If the user name or password you provided is incorrect, you will see a description of this error.
To configure a proxy
If you need to configure a proxy to allow the Connector to reach the Internet, you can do it using the Connector's web interface. 1. Go to the Network tab, click Configure Proxy.
2.
The Network Configuration:Proxy page appears. Provide the information required and click Configure Proxy.
After using the web browser to register the Connector with the vCenter Server, as an administrator you can import virtual machines to Amazon EC2. If you're going to import VMs using only an administrator account, skip the following section and go to Using the Connector for VMware vCenter (p. 332). If you want non-administrative users to import VMs to Amazon EC2, you must grant them permission using the vCenter.
2.
In the Add New Role dialog box, type the name for the new role and specify the following permissions. Under Global, select Cancel task. Under Tasks, select Create task and Update task. Under vApp, select Export and View OVF Environment. Click OK. To grant the new role permission to vCenter users or groups who will be importing virtual machines to Amazon EC2, right-click your specific vCenter in the tree-view pane and select Add permission. The Assign Permissions dialog box opens. In the Users and Groups box on the left, select the users or groups you want to add to the new role you created.
3.
4.
5. 6. 7.
If you don't have users defined yet, click Add. The Select Users and Groups dialog box opens. Select and add the users you want to add to the new role. When you have identified all the users for the role, click OK. In the Assigned Role box on the right of the Assign Permissions dialog box, select the role that you previously created. Clear the check box for Propagate to Child Objects and click OK. Repeat the same process to assign the role of virtual machine power user to all users and groups that you want to allow to import VMs to Amazon EC2. You can do this at the VM object level or at a higher level in the hierarchy. If you assign the role at a higher level, you must select the check box for Propagate to Child Objects.
Important
If you don't enable RDP and disable the Windows-based firewall, your VM will import successfully to Amazon EC2, but you will not be able to log in. These requirements must be satisfied: The virtual machine must be turned off. The virtual machine must only use a single virtual hard drive (multiple partitions are OK). The virtual hard drive cannot be larger than one terabyte (1TB). The Connector virtual appliance must have sufficient free hard drive space to temporarily store the compressed VMDK image while it is being imported to Amazon EC2.
To use the Connector to import a VM for the first time using an account with administrative rights
1. Log in to VMware vCenter using the VMware vSphere Client. If you had a session open while you were installing the Connector, notice that the Import to EC2 tab becomes visible.
Note
The first time you log in, you will see an SSL certificate warning. This warning indicates that the SSL certificate being used by the Connector cannot be verified by an external source.
API Version 2013-02-01 332
This is expected behavior. Your session will continue to use SSL for encryption. Check the Install this certificate and do not display a security warning option at the bottom of the screen and click Ignore. You are now logged in to the vCenter Server. 2. 3. On the left pane, navigate the tree view to the virtual machine you want to import. Select it. On the right pane, select the Import to EC2 tab.
Note
You might see another security warning about SSL certificates. Click Yes to continue. The Connector initializes. 4. In the Enter AWS Credentials dialog box, provide your Access Key ID and Secret Access Key. For information on how to get your AWS credentials, see How to Get Your Access Key ID and Secret Access Key (p. 444). The main Connector page appears when your AWS credentials are verified. Back in vCenter, select the virtual machine you want to import and go to the Import to EC2 tab.
5.
6.
In the Instance Parameters dialog box, specify the values for the following options, then click the Import to EC2 button. Region(Required) The AWS Region in which you want to launch your imported instance. Select one of the options from the drop-down list. Availability Zone(Optional) Your choice of Availability Zone in the Region that you have selected. If not specified, Amazon will select one for you. Operating System(Required) The operating system that your virtual machine is using. Selecting an incorrect value can cause the import task to fail. For virtual machines using Windows Server 2008 R2, always select Microsoft Windows Server 2008 (64-bit). If the virtual machine you're importing runs on Windows Server 2008 SP2, determine first whether the operating system is a 32-bit or 64-bit System Type then select the Operating System accordingly. For more information about 32-bit and 64-bit Windows, go to 32-bit and 64-bit Windows: frequently asked questions. For more information about how to determine System Type for Windows Server 2003, go to Microsoft Support. Instance Type(Required) The instance type to use when your virtual machine becomes an instance in EC2. Instance types allow you to choose the CPU and memory requirements. For more information on instance types and pricing, go to Amazon EC2 Pricing. Launch in VPC(Optional) Check this box if you want your virtual machine to become an instance within Amazon Virtual Private Cloud (Amazon VPC). For information, go to Amazon Virtual Private Cloud (Amazon VPC).
Subnet(Required only if launching in VPC) Select the subnet that you want your instance placed within in a VPC. Private IP address(Optional, applies only if launching in VPC) Specify the private IP address of your instance within VPC. Security Group(Required) Select the security group to use with your instance. Defaults to the default security group. The values you specified are listed in the Confirm Import Options box. Check the information and click Import. 7. Monitor the progress of the import task in the Tasks & Events or Recent Tasks tab of the VMware vSphere Client.
Export OVF templateCreates a stream-optimized VMDK image.This process consolidates your virtual machine to a single image. In addition, stream-optimized VMDKs are compressed and are well-suited for transfer over a WAN connection. The stream-optimized VMDK will be temporarily stored on your Connector virtual appliance. Import to EC2Transfers the stream-optimized VMDK that was created in the first task to Amazon EC2, and converts your virtual machine to an Amazon EC2 instance. The Import to EC2 task can take up to a few hours to complete. In addition, you might notice that the task progress will pause for up to 10 minutes at times. This is expected behavior.
Important
Keep your session in VMware vCenter open until all tasks complete. If you quit the vSphere Client or log off of your vCenter, the import task will not complete successfully, and the progress indicator will not be updated. If this occurs, you can use the command line tools to check the status of your import task. For more information, see Checking on the Status of Your Import in Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2 (p. 335). When you have verified that the task is complete, you can safely cancel the import task by right-clicking the task in the vSphere Client and selecting Cancel.
Although you can see your instance in the AWS Management Console when the import process begins, do not launch your instance until the import process completes. For information about launching instances, see Launching an Instance from an AMI (p. 274).
Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2
Topics Exporting Your Virtual Machines from Their Virtual Environment (p. 336) Importing Your Virtual Machine into Amazon EC2 (p. 341) In this section, you'll learn how to use the Amazon EC2 command line tools to import your Citrix, Microsoft Hyper-V, or VMware virtual machine to Amazon EC2. If you haven't already installed the Amazon EC2 command line tools, see Setting Up the Amazon EC2 Command Line Tools (p. 579). Importing VMs into Amazon EC2 is a two-step process. First, you export your virtual machine from the virtualization environment. Next, you create an import task and upload your virtual machine into Amazon EC2. The following diagram illustrates this process.
Use the following commands when you perform import tasks using the Amazon EC2 command line tools: Command
ec2-import-instance
Description Creates a new import instance task using metadata from the specified disk image and imports the instance to Amazon EC2. Creates a new import volume task using metadata from the specified disk image and imports the volume to Amazon EC2. Resumes the upload of a disk image associated with an import instance or import volume task ID. Lists and describes your conversion tasks.
ec2-import-volume
ec2-resume-import
ec2-describe-conversion-tasks
Command
ec2-cancel-conversion-task
Description Cancels the active conversion task. The task can be the import of an instance or volume. Deletes a partially or fully uploaded disk image for conversion from Amazon S3.
ec2-delete-disk-image
For information about these commands and other EC2 commands, go to the Amazon Elastic Compute Cloud Command Line Reference.
Note
You can use a graphical user interface provided through the Amazon EC2 VM Import Connector (Connector) to import your VMware virtual machines to Amazon EC2. For more information, see Using the Amazon EC2 VM Import Connector to Import Your Virtual Machine to Amazon EC2 (p. 321).You cannot use the Connector to import Citrix or Microsoft Hyper-V virtual machines.
2.
Using the Console, access the Control Panel of the virtual machine's Windows operating system and uninstall the Citrix Tools for Virtual Machines.
3.
After the tools are removed, reboot the virtual machine when prompted, log in again and then shut down using Windows. You can now proceed to export the VM.
Note
Do not export the image by right-clicking a stopped instance and selecting "Export to File."
2.
When the XenServer OVF Appliance Export Wizard starts, specify the destination of the VM files, click Next, accept the defaults, and proceed through the screens until you click Finish.
3.
When the export completes, you can proceed and import the VM files to Amazon EC2 by following the steps in Importing Your Virtual Machine into Amazon EC2 (p. 341) and specifying VHD as the file format.
2.
3.
In the Export Virtual Machine dialog box, for Location, click Browse, navigate to a destination location that has plenty of space, and click Export.
4.
Track the export progress through the Status of your VM in the Hyper-V Manager. Wait for the export to complete. When the export completes, you can proceed and import the VM files to Amazon EC2 by following the steps in Importing Your Virtual Machine into Amazon EC2 (p. 341) and specifying VHD as the file format. The VHD file will be located in the folder you specified in the Export Virtual Machine dialog box.
3.
From the File menu, select Export, and then Export OVF Template.
4.
In the Export OVF Template dialog box, enter a name for the disk image file and a directory to save it in.
You will see a box displaying the progress of the export. Because of the size and number of files associated with the VM, and the network connection, the export might take some time. If the connection times out, the export process will fail. If this happens, restart the export. When the export completes, vSphere saves the disk image file in the directory you specified. Use the name of the VMDK file as an argument in ec2-import-instance to import a virtual machine into Amazon EC2, or in ec2-import-volume to import a volume into Amazon Elastic Block Store (Amazon EBS).
To specify an Amazon Virtual Private Cloud (Amazon VPC) subnet to use when you create the conversion task, use the --subnet subnet_id option with the ec2-import-instance command. Otherwise your instance will use a public IP address. We recommend you use a restrictive security group to control access to your instance. For more information about the --subnet subnet_id option, see ec2-import-instance. We recommend that your instance contain strong passwords for all user accounts. We recommend that you install the EC2Config service after you import your virtual machine into Amazon EC2.
The following command creates an import instance task that imports a Windows Server 2008 SP2 (32-bit) VM into the us-east-1 Region.
Note
The example uses the VMDK format. You can also use VHD or RAW.
ec2-import-instance ./WinSvr8-2-32-disk1.vmdk f VMDK -t m1.small -a i386 -b myawsbucket -o AKIAIOSFODNN7EXAMPLE -w wJalrXUtnFEMI/K7MDENG/bPxRfi CYEXAMPLEKEY
This request uses the VMDK file, WinSvr8-2-32-disk1.vmdk, to create the import task. The output is similar to the following example.
Requesting volume size: 25 GB Disk image format: Stream-optimized VMDK Converted volume size: 26843545600 bytes (25.00 GiB) Requested EBS volume size: 26843545600 bytes (25.00 GiB) TaskType IMPORTINSTANCE TaskId import-i-fhbx6hua ExpirationTime 2011-09-09T15:03:38+00:00 Status active StatusMessage Pending InstanceID i-6ced060c DISKIMAGE DiskImageFormat VMDK DiskImageSize 5070303744 VolumeSize 25 AvailabilityZone us-east-1c Approximate BytesConverted 0 Status active StatusMessage Pending Creating new manifest at testImport/9cba4345-b73e-4469-81062756a9f5a077/Win_2008_R1_EE_64.vmdkmanifest.xml Uploading the manifest file Uploading 5070303744 bytes across 484 parts 0% |--------------------------------------------------| 100% |==================================================| Done
The following example enables you to see the status of your import instance task.
ec2-describe-conversion-tasks import-i-ffvko9js
The following response shows that the IMPORTINSTANCE status is active, and 73747456 bytes out of 893968896 have been converted.
TaskType IMPORTINSTANCE TaskId import-i-ffvko9js ExpirationTime 2011-06-07T13:30:50+00:00 Status active StatusMessage Pending InstanceID i-17912579 DISKIMAGE DiskImageFormat VMDK DiskImageSize 893968896 VolumeSize 12 AvailabilityZone us-east-1a ApproximateBytesCon verted 73747456 Status active StatusMessage Pending
The following response shows that the IMPORTINSTANCE status is active, and at 7% progress and that the DISKIMAGE is completed.
TaskType IMPORTINSTANCE TaskId import-i-ffvko9js ExpirationTime 2011-06-07T13:30:50+00:00 Status active StatusMessage Progress: 7% InstanceID i-17912579 DISKIMAGE DiskImageFormat VMDK DiskImageSize 893968896 VolumeId vol-9b59daf0 VolumeSize 12 AvailabilityZone useast-1a ApproximateBytesConverted 893968896 Status completed
Note
The IMPORTINSTANCE status is what you use to determine the final status. The DISKIMAGE status will be completed for a period of time before the IMPORTINSTANCE status is completed.
You can now use commands such as ec2-stop-instance, ec2-start-instance, ec2-reboot-instance, and ec2-terminate-instance to manage your instance.
Note
By default, when you terminate an instance, Amazon EC2 does not delete the associated Amazon EBS volume. You can optionally use the ec2-modify-instance-attribute command to change this behavior.
Important
We recommend utilizing Amazon EC2 security groups to limit network access to your imported instance. Configure a security group to allow only trusted Amazon EC2 instances and remote hosts to connect to RDP and other service ports. For more information about security groups, see Amazon EC2 Security Groups (p. 426). After you have exported your virtual machine from the virtualization environment, importing the volume to Amazon EBS is a single-step process. You create an import task and upload the volume in one step, as illustrated in the following diagram.
The following example creates an import volume task for importing a volume to the us-east-1a Region.
Note
The example uses the VMDK format. You can also use VHD or RAW.
Requesting volume size: 25 GB Disk image format: Stream-optimized VMDK Converted volume size: 26843545600 bytes (25.00 GiB) Requested EBS volume size: 26843545600 bytes (25.00 GiB) TaskType IMPORTVOLUME TaskId import-vol-ffut5xv4 ExpirationTime 2011-09-09T15:22:30+00:00 Status active StatusMessage Pending DISKIMAGE DiskImageFormat VMDK DiskImageSize 5070303744
VolumeSize 25 AvailabilityZone us-east-1d BytesConverted 0 Creating new manifest at tesdfgting/0fd8fcf5-04d8-44ae-981f3c9f56d04520/Win_2008_R1_EE_64.vmdkmanifest.xml Uploading the manifest file Uploading 5070303744 bytes across 484 parts 0% |--------------------------------------------------| 100% |==================================================| Done
Approximate
Amazon EC2 returns a task ID that you use in the next step. In this example, the ID is import-vol-ffut5xv4. 2. Use ec2-describe-conversion-tasks to confirm that your volume imported successfully.
$ ec2-describe-conversion-tasks import-vol-ffut5xv4 TaskType IMPORTVOLUME TaskId import-vol-ffut5xv4 ExpirationTime 2011-09-09T15:22:30+00:00 Status completed DISKIMAGE DiskImageFormat VMDK DiskImageSize 5070303744 VolumeId vol-365a385c VolumeSize 25 AvailabilityZone us-east-1d ApproximateBytesConverted 5070303744
The status in this example is completed, which means the import succeeded. 3. Use ec2-attach-volume to attach the Amazon EBS volume to one of your existing Amazon EC2 instances. The following example attaches the volume, vol-2540994c, to the i-a149ec4a instance on the device, /dev/sde.
$ ec2-attach-volume vol-2540994c -i i-a149ec4a -d /dev/sde ATTACHMENT vol-2540994c i-a149ec4a /dev/sde attaching 2010-0323T15:43:46+00:00
Resuming an Upload
Connectivity problems can interrupt an upload. When you resume an upload, Amazon EC2 automatically starts the upload from where it stopped. The following procedure steps you through determining how much of an upload succeeded and how to resume it.
To resume an upload
Use the task ID with ec2-resume-import to continue the upload. The command uses the HTTP HEAD action to determine where to resume.
ec2-resume-import DISK_IMAGE_FILENAME -t TASK_ID -o OWNER -w SECRETKEY
Done Average speed was 10.316 MBps The disk image for import-i-ffni8aei has been uploaded to Amazon S3 where it is being converted into an EC2 instance. You may monitor the progress of this task by running ec2-describe-conversion-tasks. When the task is completed, you may use ec2-delete-disk-image to remove the image from S3.
Canceling an Upload
Use ec2-cancel-conversion-task to cancel an active conversion task. The task can be the upload of an instance or a volume. The command removes all artifacts of the conversion, including uploaded volumes or instances. If the conversion is complete or still transferring the final disk image, the command fails and returns an exception similar to the following:
Client.CancelConversionTask Error: Failed to cancel conversion task import-ifh95npoc
You can use the ec2-describe-conversion-tasks command to check the status of the cancellation. For example:
$ ./ec2-describe-conversion-tasks import-i-fh95npoc TaskType IMPORTINSTANCE TaskId import-i-fh95npoc ExpirationTime 2010-12-20T18:36:39+00:00 Status cancelled InstanceID i-825063ef DISKIMAGE DiskImageFormat VMDK DiskImageSize 2671981568 VolumeSize 40 AvailabilityZone us-east-1c ApproximateBytesCon verted 0 Status cancelled
In the above example, the status is cancelled. If it were still in process, the status would be cancelling.
The following example deletes the disk image associated with the task ID, import-i-fh95npoc.
PROMPT> ec2-delete-disk-image import-i-fh95npoc
Operating Systems
The following operating systems can be exported from Amazon EC2: Windows Server 2003 R2 (Standard, Enterprise, and Datacenter) Windows Server 2008 (Standard, Enterprise, and Datacenter) Windows Server 2008 R2 (Standard, Enterprise, and Datacenter)
Image Formats
We support the following image formats for exporting both volumes and instances from Amazon Web Services (AWS): Stream-optimized ESX Virtual Machine Disk (VMDK) image format, which is compatible with VMware ESX and VMware vSphere versions 4 and 5 virtualization products. Open Virtual Appliance (OVA) image format, which is compatible with VMware vSphere versions 4 and 5. Virtual Hard Disk (VHD) image format, which is compatible with Citrix Xen and Microsoft Hyper-V virtualization products.
Known Limitations
The exporting of instances and volumes is subject to the following limitations: You cannot export Amazon Elastic Block Store (Amazon EBS) data volumes. You cannot export an instance that has more than one virtual disk. You cannot export an instance that has more than one network interface.
Export an Instance
You can use the Amazon EC2 command line interface (CLI) to export an instance. The ec2-create-instance-export-task command gathers all of the information necessary (e.g., instance ID; name of the S3 bucket that will hold the exported image; name of the exported image; VMDK, OVA, or VHD format) to properly export the instance to the selected virtualization format. The exported file is saved in the Amazon Simple Storage Service (Amazon S3) bucket that you designate.
Note
When you export an instance, you are charged the standard Amazon S3 rates for the bucket where the exported VM is stored. In addition, a small charge reflecting temporary use of an EBS snapshot might appear on your bill. For more information about Amazon S3 pricing, see Amazon Simple Storage Service (S3) Pricing.
To export an instance
1. Create an Amazon S3 bucket where exported instances will be stored. The S3 bucket must grant Upload/Delete and View Permissions access to the vm-import-export@amazon.com account. For more information, see Creating a Bucket and Editing Bucket Permissions in the Amazon Simple Storage Service User Guide. At a command prompt, type the following command: ec2-create-instance-export-task INSTANCE_ID e TARGET_ENVIRONMENT f DISK_IMAGE_FORMAT -c CONTAINER_FORMAT b S3_BUCKET Where:
INSTANCE_ID is the ID of the instance you want to export. TARGET_ENVIRONMENT is VMware, Citrix, or Microsoft. DISK_IMAGE_FORMAT is VMDK for VMware or VHD for Microsoft Hyper-V and Citrix Xen. CONTAINER_FORMAT may be optionally set to OVA when exporting to VMware. S3_BUCKET is the name of the Amazon S3 bucket to which you want to export the instance.
2.
3.
To monitor the export of your instance, at the command prompt, type the following command: ec2-describe-export-tasks TASK_ID Where:
TASK_ID is the ID of the export task.
Managing Instances
Topics Auto Scaling and Load Balancing Your Instances (p. 349) Monitoring Your Instances (p. 351) Ensuring Idempotency (p. 372) Instance Metadata (p. 374) This section describes features that help you manage your instances.
Auto Scaling
Auto Scaling enables you to scale the number of instances that you are using up or down, based on parameters that you specify, such as traffic or CPU load. Auto Scaling also monitors the health of each Amazon EC2 instance that it launches. If any instance terminates unexpectedly, Auto Scaling detects the termination and launches a replacement instance. For a high degree of flexibility, you can organize Amazon EC2 instances into Auto Scaling groups, which enable you to scale different server classes (for example, web servers, back-end servers) at different rates. For each group, you specify the minimum number of instances, the maximum number of instances, and the parameters to increase and decrease the number of running instances. For information about setting up Auto Scaling, go to the Amazon Auto Scaling Developer Guide.
Load Balancing
Elastic Load Balancing enables you to automatically distribute the incoming traffic (or load) among all instances that you are running. The service also makes it easy for you to add new instances when you need to increase the capacity of your application. Customers reach your web site through your web URL, such as www.mywebsite.com. This single address might actually represent several instances of your running web application. To always have an available web site, you need to run multiple instances. Otherwise, your customers might see delays when accessing your site, or worse, might not be able to access your site at all. Elastic Load Balancing manages incoming requests by optimally routing traffic so that no one instance is overwhelmed. You can quickly add more instances to applications that are experiencing an upsurge in traffic, or remove capacity when traffic is slow.
Amazon Elastic Compute Cloud User Guide Auto Scaling and Load Balancing Your Instances
For information about setting up Elastic Load Balancing, go to the Elastic Load Balancing Developer Guide.
For information about monitoring your Amazon EBS volumes, see Monitoring the Status of Your Volumes (p. 508).
Monitoring Instances
The following table describes the types of monitoring data available for your Amazon EC2 instances. Resource Instances Type Basic Description Data is available automatically in 5-minute periods at no charge.
Detailed
Data is available in 1-minute periods at an additional cost. To get this level of data, you must specifically enable it for the instance. For the instances where you've enabled detailed monitoring, you can also get aggregated data across groups of similar instances. For information about pricing, go to the Amazon CloudWatch product page.
You can get monitoring data for your Amazon EC2 instances using either the Amazon CloudWatch API or the AWS Management Console. The console displays a series of graphs based on the raw data from the Amazon CloudWatch API. Depending on your needs, you might prefer to use either the data from the API or the graphs in the console.
Metric
CPUUtilization
Description The percentage of allocated EC2 compute units that are currently in use on the instance. This metric identifies the processing power required to run an application upon a selected instance. Units: Percent
DiskReadOps
Completed read operations from all ephemeral disks available to the instance (if your instance uses Amazon EBS, see Amazon EBS Metrics (p. 508).) This metric identifies the rate at which an application reads a disk. This can be used to determine the speed in which an application reads data from a hard disk. Units: Count
DiskWriteOps
Completed write operations to all ephemeral disks available to the instance (if your instance uses Amazon EBS, see Amazon EBS Metrics (p. 508).) This metric identifies the rate at which an application writes to a hard disk. This can be used to determine the speed in which an application saves data to a hard disk. Units: Count
DiskReadBytes
Bytes read from all ephemeral disks available to the instance (if your instance uses Amazon EBS, see Amazon EBS Metrics (p. 508).) This metric is used to determine the volume of the data the application reads from the hard disk of the instance. This can be used to determine the speed of the application. Units: Bytes
DiskWriteBytes
Bytes written to all ephemeral disks available to the instance (if your instance uses Amazon EBS, see Amazon EBS Metrics (p. 508).) This metric is used to determine the volume of the data the application writes onto the hard disk of the instance. This can be used to determine the speed of the application. Units: Bytes
NetworkIn
The number of bytes received on all network interfaces by the instance. This metric identifies the volume of incoming network traffic to an application on a single instance. Units: Bytes
NetworkOut
The number of bytes sent out on all network interfaces by the instance. This metric identifies the volume of outgoing network traffic to an application on a single instance. Units: Bytes
Metric
StatusCheckFailed
Description A combination of StatusCheckFailed_Instance and StatusCheckFailed_System that reports if either of the status checks has failed. Values for this metric are either 0 (zero) or 1 (one.) A zero indicates that the status check passed. A one indicates a status check failure.
Note
Status check metrics are available at 5 minute frequency and are not available in Detailed Monitoring. For a newly launched instance, status check metric data will only be available after the instance has completed the initialization state. Status check metrics will become available within a few minutes of being in the running state. Units: Count
StatusCheckFailed_Instance Reports whether the instance has passed the EC2 instance status check in the last 5 minutes. Values for this metric are either 0 (zero) or 1 (one.) A zero indicates that the status check passed. A one indicates a status check failure.
Note
Status check metrics are available at 5 minute frequency and are not available in Detailed Monitoring. For a newly launched instance, status check metric data will only be available after the instance has completed the initialization state. Status check metrics will become available within a few minutes of being in the running state. Units: Count
StatusCheckFailed_System Reports whether the instance has passed the EC2 system status check in the last 5 minutes. Values for this metric are either 0 (zero) or 1 (one.) A zero indicates that the status check passed. A one indicates a status check failure.
Note
Status check metrics are available at 5 minute frequency and are not available in Detailed Monitoring. For a newly launched instance, status check metric data will only be available after the instance has completed the initialization state. Status check metrics will become available within a few minutes of being in the running state. Units: Count
Note
When you get data from Amazon CloudWatch, you can include a Period request parameter to specify the granularity of the returned data. This is different than the period we use when we collect the data (either 1-minute periods for detailed monitoring, or 5-minute periods for basic monitoring). We recommend that you specify a period in your request that is equal to or larger than the collection period to ensure that the returned data is valid. You can use the dimensions in the following table to refine the metrics returned for your instances.
Dimension
AutoScalingGroupName
Description This dimension filters the data you request for all instances in a specified capacity group. An AutoScalingGroup is a collection of instances you define if you're using the Auto Scaling service. This dimension is available only for EC2 metrics when the instances are in such an AutoScalingGroup. Available for instances with Detailed or Basic Monitoring enabled. This dimension filters the data you request for all instances running this EC2 Amazon Machine Image (AMI). Available for instances with Detailed Monitoring enabled. This dimension filters the data you request for the identified instance only. This helps you pinpoint an exact instance from which to monitor data. Available for instances with Detailed Monitoring enabled. This dimension filters the data you request for all instances running with this specified instance type. This helps you categorize your data by the type of instance running. For example, you might compare data from an m1.small instance and an m1.large instance to determine which has the better business value for your application. Available for instances with Detailed Monitoring enabled.
ImageId
InstanceId
InstanceType
For more information about using the GetMetricStatistics action, go to GetMetricStatistics in the Amazon CloudWatch API Reference.
Summary Disk Read Operations (Count) Summary Disk Write Operations (Count) Summary Status (Any) Summary Status Instance (Count) Summary Status System (Count) The AWS Management Console contains a console for Amazon CloudWatch. In the Amazon CloudWatch console you can search and browse all your AWS resource metrics, view graphs to troubleshoot issues and discover trends, create and edit alarms to be notified of problems, and see at-a-glance overviews of your alarms and AWS resources. For more information, go to AWS Management Console in the Amazon CloudWatch Developer Guide.
console in the AWS Management Console displays monitoring graphs with a 1-minute period for the instance. You can enable or disable detailed monitoring using the console or the command line interface (CLI).
For information about launching instances, see Launching Amazon EC2 Instances (p. 274).
Detailed data (collected with a 1-minute period) is then available for the instance in the AWS Management Console graphs or through the API.
Amazon EC2 returns output similar to the following example. The status of monitoring is listed as monitoring-enabled.
RESERVATION r-7430c31d 111122223333 default INSTANCE i-ae0bf0c7 ami-2bb65342 pending gsg-keypair 0 m1.small 2008-03-21T16:19:25+0000 us-east-1a monitoring-enabled
After the instance is running, detailed data (collected with a 1-minute period) is then available for the instance in the AWS Management Console graphs or through the API.
After the instance is launched, detailed data (collected with a one-minute period) is then available for the instance in the AWS Management Console graphs or through the API.
Detailed data (collected with a one-minute period) is then available for the instance in the AWS Management Console graphs or through the API.
5. 6.
Note
A shorter period creates a more sensitive alarm. A longer period can mitigate brief spikes in a metric. d. In Alarm name, a name is automatically generated for you. Click Edit if you want to change the name.
Important
You cannot modify the name after you create the alarm.
7.
After you create the alarm, you can use the Monitoring tab in the Amazon EC2 console to view a summary of alarms that have been set for that instance. From there, you can also edit the alarm.
Note
If you created a new Amazon SNS topic for this alarm or added new email addresses to an existing topic, each email address added will receive a subscription confirmation email from Amazon SNS. The person who receives the email must confirm it by clicking the included link in order to receive notifications.
4.
In the Create Alarm for dialog box, select the Send a notification to check box, and then choose an existing Amazon Simple Notification Service (SNS) topic or create a new SNS topic to use for this alarm.
5. 6. 7.
8.
In the With these recipients box, type your email address (e.g., john.stiles@example.com) and the addresses of any additional recipients, separated by commas. In the Whenever drop-down list, select the status check you want to be notified about (e.g., Status Check Failed (Any), Status Check Failed (Instance), or Status Check Failed (System)). In the For at least box, set the number of periods you want to evaluate (for example, 2) and in the consecutive periods drop-down menu, select the evaluation period duration (for example, 5 minutes) before triggering the alarm and sending an email To change the default name for the alarm, in the Name this alarm box, type a friendly name for the alarm (for example, StatusCheckFailed), and then click Create Alarm.
Important
If you added an email address to the list of recipients or created a new topic, Amazon SNS will send a subscription confirmation email message to each new address shortly after you create an alarm. Remember to click the link contained in that message, which confirms your subscription. Alert notifications are only sent to confirmed addresses.
Command Line Interface To create a status check alarm using the CLI
You can create a status check alarm using the Amazon CloudWatch CLI. In the following example, the alarm publishes a notification to a specific SNS topic that has the ARN arn:aws:sns:us-east-1:1111111111:StatusCheckNotifications when instance i-ab12345 fails either the instance check or system status check for at least two periods. (The metric is StatusCheckFailed.) For more information, see the mon-put-metric-alarm command in the Amazon CloudWatch Developer Guide.
mon-put-metric-alarm --alarm-name StatusCheckFailed-Alarm-for-i-ab12345 --alarm-description "Alarm when StatusCheckFailed metric has a value of one for two periods" --metric-name StatusCheckFailed --namespace AWS/EC2 --statistic Maximum --period 300 --threshold 1 --comparison-operator GreaterThanThreshold -dimensions "InstanceId=i-ab12345" --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:1111111111StatusCheckNotifications --unit Count
Where: The --alarm-name is the name of the alarm. This is required. The --alarm-description is a friendly description of the alarm. The --metric-name is one of the available status metrics (e.g., StatusCheckFailed, StatusCheckFailed_Instance, or StatusCheckFailed_System). This is required. The --statistic is one of the following values: Average, Sum, Minimum, or Maximum. This is required. The -period is the time frame (in seconds) in which Amazon CloudWatch metrics are collected. In this example, you would enter 300, which is 60 seconds multiplied by 5 minutes. This is required. The --threshold is the value to which the metric will be compared (e.g., 1). This is required. The --namespace is the metrics namespace (e.g., AWS/EC2). This is required. The --dimensions are associated with the metric (e.g., InstanceId=i-ab12345). The --evaluation-periods is the number of consecutive periods for which the value of the metric must be compared to the threshold. This is required. The --alarm-actions is the list of actions to perform when this alarm is triggered. Each action is specified as an Amazon Resource Number (ARN). In this example, we want the alarm to send us an email using Amazon SNS.
Note
You can find the ARN for the Amazon SNS topic that the alarm will use in the Amazon SNS console: 1. 2. 3. Open the Amazon SNS console at https://console.aws.amazon.com/sns/. On the Navigation pane, under My Topics, select the topic you want the alarm to send mail to. The ARN is located in the Topic ARN field on the Topic Details pane.
The --unit is the unit of the metric on which to alarm (e.g., Count).
1. 2.
3.
At a command prompt, type mon-list-metrics --headers to view the list of all available Amazon CloudWatch metrics for the services in AWS that you're using. In the list of metrics, look in the Namespace column (second column), and review the Status Check metrics that have the AWS/EC2 namespace. These are the status check metrics that you can use to create a status check alarm. At the command prompt, enter the following command:
Instance status checks monitor the software and network configuration of your individual instance. These checks detect problems that require your involvement to repair. When an instance status check fails, typically you will need to address the problem yourself (for example by rebooting the instance or by making modifications in your operating system). Examples of problems that may cause instance status checks to fail include: Failed system status checks Misconfigured networking or startup configuration Exhausted memory Corrupted file system Incompatible kernel
Note
Status checks that occur during instance reboot or while a Windows instance store-backed instance is being bundled will report an instance status check failure until the instance becomes available again.
Viewing Status
AWS provides you with several ways to view and work with status checks: You can use the AWS Management Console, interact directly with the API, or use the command line interface.
4.
To view an individual instances status, select the instance, and then click the Status Checks tab.
Note
If you have an instance with a failed status check and the instance has been unreachable for over 20 minutes, you can click Contact Support to submit a request for assistance. To try and troubleshoot system or instance status check failures yourself, see Troubleshooting Instances with Failed Status Checks (p. 399).
Get the status of all instances with a instance status ec2-describe-instance-status --filter of impaired "instance-status.status=impaired" Get the status of all instances with a single instance ec2-describe-instance-status status with instance ID i-15a4417c i-15a4417c
For more information about using the ec2-describe-instance-status command, see ec2-describe-instance-status in the Amazon Elastic Compute Cloud Command Reference Guide.
Note
If you have an instance with a failed status check, see Troubleshooting Instances with Failed Status Checks (p. 399)
API
You can use the DescribeInstanceStatus action to retrieve the status of your instances. For more information, see DescribeInstanceStatus in the Amazon Elastic Compute Cloud API Reference Guide.
Reporting Status
You can provide feedback about your instances if you are having problems with an instance whose status is not shown as impaired, or to send AWS additional details about the problems you are experiencing with an impaired instance. We use reported feedback to identify issues impacting multiple customers, but do not respond to individual account issues reported via this form. Providing feedback will not change the status check results that you currently see for this instance. If you are in need of technical assistance specific to your account, please post your question to the Developer Forums or contact Premium Support.
AWS Management Console To report status feedback using the management console
1. 2. 3. 4. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. In the Navigation pane, click Instances. On the Instances page, click on the instance on which you want to report status. Click the Status Checks tab and then click the Submit Feedback button.
5.
For more information about using the ec2-report-instance-status command, see ec2-report-instance-status in the Amazon Elastic Compute Cloud Command Reference Guide.
API
You can use the ReportInstanceStatus action to submit feedback about a running instance's status. If your experience with the instance differs from the instance status returned by the DescribeInstanceStatus action, use ReportInstanceStatus to report your experience with the instance. Amazon EC2 collects this information to improve the accuracy of status checks. For more information, see ReportInstanceStatus in the Amazon Elastic Compute Cloud API Reference Guide.
Instance reboot: AWS may schedule an instance for a reboot for necessary maintenance, such as to apply patch upgrades to an underlying host that do not require the host to be rebooted. System reboot: AWS may schedule an instance for a reboot for necessary maintenance, such as to apply patch upgrades that do require the host to be rebooted. Network maintenance: AWS may schedule network maintenance that includes a scheduled start and end time, during which your instances will not have network connectivity. You will be notified by email if one of your instances is set for network maintenance. The email message indicates when your instance will not have network connectivity. Power maintenance: AWS may schedule power maintenance that includes a scheduled start and end time, during which your instances may be offline for an extended period and then be rebooted. You will be notified by email if one of your instances is set for power maintenance. The email message indicates when your instance will be rebooted. Instance retirement: AWS may schedule instances for retirement in cases where there is an unrecoverable issue with the hardware on an underlying host. You will also be notified by email if one of your instances is set to retiring.The email message indicates when your instance will be permanently retired. Instance stop: AWS may schedule instances to stop in cases where there is an unrecoverable issue with the hardware on an underlying host. You will also be notified by email if one of your instances is set to stop. The email message indicates when your instance will be stopped.
Important
No action is required on your part if one of your instances is scheduled for reboot. We recommend that you wait for the reboot to occur within its scheduled maintenance window. For instances scheduled for network maintenance, power maintenance, stop, or retirement, we recommend that you take the actions detailed later in this section.
For more information about using the ec2-describe-instance-status command, see ec2-describe-instance-status in the Amazon Elastic Compute Cloud Command Reference Guide.
API
You can use the DescribeInstanceStatus action to retrieve the status of your instances. For more information, see DescribeInstanceStatus in the Amazon Elastic Compute Cloud API Reference Guide.
Important
No action is required on your part if one of your instances is scheduled for reboot. We recommend that you wait for the reboot to occur automatically within its scheduled maintenance window. Scheduled reboot events start within their scheduled maintenance window. After initiation, both system and instance reboots typically complete in a matter of minutes. After a reboot completes, your instance is available to use; it is not necessary to wait until the scheduled end time. To verify that the reboot has occurred, check your scheduled events and verify that the instance no longer shows a scheduled event. We recommend that you check your instance after it is rebooted to ensure that your application is functioning as you expected.
Note
After you perform the reboot, the scheduled event for the instance reboot is canceled immediately. The event's description is updated in the AWS console to reflect this. System Reboot If you choose to perform a system reboot, your course of action will differ depending on whether your instances root device volume is an EBS volume or an instance store volume. You can determine the root device type for an instance using either the DescribeInstances API or the AWS Management Console. In the console, you select an instance and view the root device type listed in the Description tab.
Before you stop and restart an instance, perform the following tasks: 1. Retrieve any data from instance store that you will need later. This data will not be available after you stop and restart an instance.
2. Take a snapshot of your existing volume (storage charges will apply). 3. Note the necessary configuration data in case you will need it later, including the DNS public name and the private IP address. 4. Stop and restart your instance. For more information, see Stopping and Starting Instances (p. 386). 5. Re-associate an Elastic IP address if this address is necessary. 6. If other applications or instances rely on the public DNS name or the private IP address of this instance, update the information with the new configuration data.
Note
After you stop and restart the instance, the scheduled event for the system reboot is canceled immediately. The event's description is updated in the AWS console to reflect this.
Before you stop and restart an instance, perform the following tasks: 1. Retrieve any data from instance store that you will need later. This data will not be available after you stop and restart an instance.
API Version 2013-02-01 371
2. Take a snapshot of your existing volume (storage charges will apply). 3. Note the necessary configuration data in case you will need it later, including the DNS public name and the private IP address. 4. Stop and restart your instance. For more information, see Stopping and Starting Instances (p. 386). 5. Re-associate an Elastic IP address, if this address is necessary. 6. If other applications or instances rely on the public DNS name or the private IP address of this instance, update the information with the new configuration data.
Note
After you stop and restart the instance, the scheduled event is canceled immediately. The event's description is updated in the AWS console to reflect this.
Ensuring Idempotency
When you launch an instance through the API or the command line interface tools (CLI), you can optionally provide a client token to ensure the request is idempotent. If timeouts or connection errors occur, you can repeat the request and be sure you haven't launched more instances than you intended. The token must be a unique, case-sensitive string of up to 64 ASCII characters. If you repeat the request with the same client token, the same response is returned for each repeated request. The only information that might vary in the response is the state of the instance (e.g., pending). The client token is included in the response when you describe the instance. If you repeat the request with the same client token, but change another request parameter, Amazon EC2 returns an IdempotentParameterMismatch error. The client token is valid for at least 24 hours after the termination of the instance. You should not reuse a client token for another call later on. You can use the same client token for the same request across different regions. For example, if you send an idempotent request to launch an instance in the us-east-1 Region, and you use the same exact call (with the same client token) in each of the other regions, the result is a different running instance in each region. The following table shows common response codes and the recommended course of action.
Retry No effect
Comments After you receive a 200, the request has succeeded and any further retries have no effect. A 400 response typically indicates the request will never succeed (for example when a specified parameter value is not valid). In certain specific cases relating to resources that are transitioning between states, a repeat of the request could possibly succeed (e.g., launching an instance against an Amazon EBS volume that is currently transitioning to the available state). These errors are generally transient. Repeat the request with an appropriate back-off strategy. These errors can occur in times of extreme load. Repeat the request with an appropriate back-off strategy.
Not recommended
Recommended
Recommended
API
Use the RunInstances action.
Instance Metadata
Topics Data Retrieval (p. 374) Use Case: AMI Launch Index Value (p. 377) Metadata Categories (p. 380) Amazon EC2 instances can access instance-specific metadata, as well as data supplied when launching the instances, using a specific URI. You can use this data to build more generic AMIs that can be modified by configuration files supplied at launch time. For example, if you run web servers for various small businesses, they can all use the same AMI and retrieve their content from the Amazon S3 bucket you specify at launch. To add a new customer at any time, simply create a bucket for the customer, add their content, and launch your AMI. Metadata is divided into categories. For more infomation about the categories, see Metadata Categories (p. 380).
Data Retrieval
Retrieve instance metadata from within a running instance using the following: GET http://169.254.169.254/latest/meta-data/
Note
You are not billed for HTTP requests used to retrieve metadata and user-supplied data.
Metadata Retrieval
Requests for a specific metadata resource returns the appropriate value, or a 404 HTTP error code if the resource is not available. All metadata is returned as text (content type text/plain). Requests for a general metadata resource (the URI ends with a /) return a list of available resources, or a 404 HTTP error code if there is no such resource. The list items are on separate lines terminated by line feeds (ASCII 10).
Examples
The following examples list HTTP GET requests and responses on Linux instances.
Note
On Windows instances, you can install a tool such as cURL or GNU Wget to request instance metadata. This example gets the available versions of the instance metadata. These versions do not necessarily correlate with an Amazon EC2 API version.
GET http://169.254.169.254/ 1.0 2007-01-19 2007-03-01
This example gets the top-level metadata items. Some of these items are available only for instances in a VPC. For more information about each of these items, see Metadata Categories (p. 380).
GET http://169.254.169.254/latest/meta-data/ amiid ami-launch-index ami-manifest-path block-device-mapping/ hostname instance-action instance-id instance-type kernel-id local-hostname local-ipv4 ipv4-associations mac network/ placement/ public-hostname public-ipv4 public-keys/ reservation-id security-groups
This example gets the value of some of the metadata items from the preceding example.
GET http://169.254.169.254/latest/meta-data/ami-manifest-path my-amis/spamd-image.manifest.xml GET http://169.254.169.254/latest/meta-data/ami-id ami-2bb65342 GET http://169.254.169.254/latest/meta-data/reservation-id r-fea54097 GET http://169.254.169.254/latest/meta-data/hostname ec2-67-202-51-223.compute-1.amazonaws.com
This example gets public key 0 (in the OpenSSH key format).
GET http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key ssh-rsa AAAA.....wZEf my-public-key
This example gets the product code (s) associated with the AMI. Product codes are returned one per line.
GET http://169.254.169.254/latest/meta-data/product-codes 774F4FF8 ...
This example shows the network information available for an Amazon EC2-Classic/NAT instance.
GET http://169.254.169.254/latest/meta-data/network/inter faces/macs/02:29:96:8f:6a:2d/ local-hostname local-ipv4s mac public-ipv4s security-group-ids subnet-id subnet-ipv4-cidr-block vpc-id vpc-ipv4-cidr-block
This example gets the subnet ID for an Amazon EC2 instance launched into a VPC.
GET http://169.254.169.254/latest/meta-data/network/inter faces/macs/02:29:96:8f:6a:2d/subnet-id subnet-be9b61d7
This example shows the network information available for an Amazon EC2-Classic instance (one not running in an Amazon EC2-VPC).
GET http://169.254.169.254/latest/meta-data/network/inter faces/macs/03:15:28:7g:5b:8a/ local-hostname local-ipv4s mac public-ipv4s public-hostname
Note
All user-supplied data is treated as opaque data; what you give us is what you get back. It is the responsibility of the instance to interpret this data appropriately.
Example
This shows an example of returning comma-separated, user-supplied data.
GET http://169.254.169.254/latest/user-data 1234,fred,reboot,true | 4512,jimbo, | 173,,,
You can modify the user data for an Amazon EBS-backed instance while the instance is stopped. For more information, see Modifying Attributes of a Stopped Instance (p. 396).
The store-size=123PB backup-every=5min defines the master database configuration, replicate-every=1min defines the first replicant's configuration, replicate-every=2min defines the second replicant's configuration, and so on. Alice launches four instances.
PROMPT> ec2-run-instances ami-2bb65342 -n 4 -d "store-size=123PB backupevery=5min | replicate-every=1min | replicate-every=2min | replicate-every=10min | replicate-every=20min"
RESERVATION r-fea54097 598916040194 default INSTANCE i-3ea74257 ami-2bb65342 pending 0 m1.small 2010-03-19T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs INSTANCE i-31a74258 ami-2bb65342 pending 0 m1.small 2010-03-19T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs INSTANCE i-31a74259 ami-2bb65342 pending 0 m1.small 2010-03-19T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs INSTANCE i-31a7425a ami-2bb65342 pending 0 m1.small 2010-03-19T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled ebs
After they're launched, all instances have a copy of the user data and the common metadata shown here ( where ami_id represents the latest version of an AMI): AMI id: ami-id Reservation ID: r-fea54097 Public keys: none Security group names: default Instance type: m1.small However, each instance has certain unique metadata. Instance 1 Metadata instance-id ami-launch-index public-hostname public-ipv4 local-hostname local-ipv4 Value i-3ea74257 0 ec2-67-202-51-223.compute-1.amazonaws.com 67.202.51.223 ip-10-251-50-35.ec2.internal 10.251.50.35
Instance 2 Metadata instance-id ami-launch-index public-hostname public-ipv4 local-hostname local-ipv4 Value i-31a74258 1 ec2-67-202-51-224.compute-1.amazonaws.com 67.202.51.224 ip-10-251-50-36.ec2.internal 10.251.50.36
Instance 3
Instance 4 Metadata instance-id ami-launch-index public-hostname public-ipv4 local-hostname local-ipv4 Value i-31a7425a 3 ec2-67-202-51-226.compute-1.amazonaws.com 67.202.51.226 ip-10-251-50-38.ec2.internal 10.251.50.38
Therefore, an instance can determine its portion of the user-supplied data through the following process.
Metadata Categories
The data available to instances is categorized into metadata and user-supplied data. The following table lists the categories of metadata. Data
ami-id
Description The AMI ID used to launch the instance. The index of this instance in the reservation.
ami-launch-index
ami-manifest-path
The manifest path of the AMI with which 1.0 the instance was launched. The AMI IDs of any instances that were 2007-10-10 rebundled to create this AMI. Will only exist if the AMI manifest file contained an ancestor-amis key. Returns the ami, root, ebs, 2007-12-15 ephemeral, and swap files (associated virtual devices) as described below. The virtual device that contains the root/boot file system. 2007-12-15
ancestor-ami-ids
block-device-mapping/
block-device-mapping/ami
block-device-mapping/ebs N
The virtual devices associated with 2007-12-15 Amazon EBS volumes, if any are present. Only available in metadata if it is present at launch time. The N indicates the index of the Amazon EBS volume (such as ebs1 or ebs2). The virtual devices associated with 2007-12-15 ephemeral devices, if any are present. The N indicates the index of the ephemeral volume. The virtual devices or partitions associated with the root devices or partitions on the ami virtual device, where the root (/ or C:) file system is associated with the given instance. The virtual devices associated with swap. Not always present. 2007-12-15
block-device-mapping/eph emeral N
block-device-mapping/root
block-device-mapping/swap
2007-12-15
iam/info
Returns information about the last time 2012-06-01 the instance profile was updated, including the instance's LastUpdated date, InstanceProfileArn, and InstanceProfileId.
Data
iam/security-credentials /role-name
Description Where role-name is the name of the IAM role associated with the instance. Returns the temporary security credentials (AccessKeyId, SecretAccessKey, SessionToken, and Expiration) associated with the IAM role.
instance-action
Notifies the instance that it should 2008-09-01 reboot in preparation for bundling. Valid values: none | shutdown | bundle-pending. The ID of this instance. 1.0
instance-id instance-type
The type of instance. For more 2007-08-29 information, see Instance Families and Types (p. 89). The ID of the kernel launched with this 2008-02-01 instance, if applicable. The local hostname of the instance. In 2007-01-19 cases where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0). The private IP address of the instance. 1.0 In cases where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0). The instance's MAC address. In cases 2011-01-01 where multiple network interfaces are present, this refers to the eth0 device (the device for which device-number is 0). The device-number associated with that 2011-01-01 interface. Each interface must have a unique device number. The device-number serves as a hint to device naming in the instance; for example, device-number is 2 for the eth2 device. The private IPv4 address(es) that are 2011-01-01 associated with each public-ip address and assigned to that interface. The interface's local hostname. The private IP addresses associated with the interface. 2011-01-01 2011-01-01
kernel-id
local-hostname
local-ipv4
mac
network/interfaces/macs/ mac/device-number
Data
network/interfaces/macs/ mac/mac network/interfaces/macs/ mac/owner-id
The ID of the owner of the network 2011-01-01 interface. In multiple-interface environments, an interface can be attached by a third party, such as Elastic Load Balancing. Traffic on an interface is always billed to the interface owner. The interface's profile. The interface's public hostname. The elastic IP addresses associated with the interface. There may be multiple IP addresses on an instance. Security groups to which the network interface belongs. 2007-12-15 2011-01-01 2011-01-01
2011-01-01
IDs of the security groups to which the 2011-01-01 network interface belongs. Returned only for Amazon EC2 instances launched into a VPC. For more information on security groups in EC2-VPC, see VPC Security Groups. The ID of the Amazon EC2-VPC subnet 2011-01-01 in which the interface resides. Returned only for Amazon EC2 instances launched into a VPC.
network/interfaces/macs/ mac/subnet-id
network/interfaces/macs/ The CIDR block of the Amazon 2011-01-01 mac/subnet-ipv4-cidr-block EC2-VPC subnet in which the interface resides. Returned only for Amazon EC2 instances launched into a VPC. network/interfaces/macs/ mac/vpc-id
The ID of the Amazon EC2-VPC in which the interface resides. Returned only for Amazon EC2 instances launched into a VPC. The Availability Zone in which the instance launched. Product codes associated with the instance, if any.
2011-01-01
2008-02-01 2007-03-01
public-hostname
The public hostname of the instance. 2007-01-19 Not returned for Amazon EC2 instances launched into a VPC. See Elastic IP Addresses (EIP) (p. 466) for more information.
Data
public-ipv4
Description
Version Introduced
The public IP address. If an elastic IP 2007-01-19 address is associated with the instance, the value returned is the elastic IP address. Public key. Only available if supplied at 1.0 instance launch time. The ID of the RAM disk specified at launch time, if applicable. ID of the reservation. The names of the security groups applied to the instance. 2007-10-10 1.0 1.0
public-keys/0/openssh-key
ramdisk-id
reservation-id security-groups
Note
Only Amazon EC2 instances launched into a VPC can have their security groups changed after launch. These changes will be reflected here and in network/interfaces/macs/mac/security-groups.
You can provide user data when you launch an instance, or when the instance is in a stopped state (for EBS-backed instances). User-supplied data is treated as opaque data: what you give us is what you get back.
Note
All instances launched together get the same user-supplied data.You can use the AMI launch index as an index into the data. User data is limited to 16 KB. This limit applies to the data in raw form, not base64-encoded form. The user data must be base64-encoded before being submitted to the API. The API command line tools perform the base64 encoding for you. The data is in base64 and is decoded before being presented to the instance. For more information about base64 encodings, see http://tools.ietf.org/html/rfc4648.
Dynamic Data
Topics Amazon EC2 instances can also include dynamic data. Dynamic data is retrieved from http://169.254.169.254/latest/dynamic/ Data
fws/instance-monitoring
Description
Version introduced
Value showing whether the customer has enabled 2009-04-04 detailed 1-minute monitoring in CloudWatch. Valid values: enabled | disabled
Data
Description
instance-identity/document JSON containing instance attributes, such as instance-id, private IP address, etc.. instance-identity/pkcs7
Used to verify the document's authenticity and content against the signature.
instance-identity/signat ure
Data that can be used by other parties to verify its 2009-04-04 origin and authenticity.
Stopping Instances
Topics Instance Stop (p. 384) Instance Termination (p. 386) Stopping and Starting Instances (p. 386) Terminating Instances (p. 388) Enabling Termination Protection for an Instance (p. 390) Changing the Instance Initiated Shutdown Behavior (p. 393) Modifying Attributes of a Stopped Instance (p. 396) You can stop instances that use Amazon EBS volumes as their root devices. When you stop an instance, it's shut down, so any data stored in the RAM of the host computer is not preserved. You're not billed for hourly usage or data transfer, but you're billed for the storage for any Amazon EBS volumes. You can restart the instance at any time with a start request. Each time you transition an instance from stopped to started, we charge a full instance hour, even if transitions happen multiple times within a single hour.
Instance Stop
When you stop a running instance, the following happens: The instance performs a normal shutdown and stops running (the status goes to stopping and then stopped) The instance retains its instance ID Any Amazon EBS volumes remain attached and the data persists Any instance store volumes don't persist The instance won't keep its public and private IP addresses. The exception is that EC2 instances launched in a VPC keep the same IP address when stopped and restarted. Any Elastic IP address mapped to the instance is unmapped. For EC2 instances launched into a VPC, the Elastic IP address remains associated with the stopped instance. When you restart the instance, the Elastic IP address is active. While the Elastic IP address is associated with the stopped instance, you're charged for the Elastic IP address. If you've registered the instance with a load balancer, it's likely that the load balancer won't be able to route traffic to your instance after you've stopped and restarted it. You must de-register the instance from the load balancer after stopping the instance, and then re-register after starting the instance. For more information, see De-Registering and Registering Amazon EC2 Instances section in the Elastic Load Balancer Developer Guide.
When a Windows instance is stopped and restarted, the drive letters mapped to the attached EBS volumes are likely to change. For information on changing this default behavior, see Using EC2Config Service in the Microsoft Windows Guide. The next sections provide more detail about some of the areas covered in the preceding list. Network When you stop an EC2 instance, it'll lose its current public and private IP addresses and receive new ones when you restart the instance. The exception is that EC2 instances launched into a VPC keep their private IP address when stopped and restarted. Therefore, it's possible to have an Amazon EC2-VPC subnet with no running instances (they're all stopped), and also no remaining IP addresses available. When you restart a Windows instance, by default, EC2ConfigService changes the instance host name to match the new IP address and initiates a reboot. For more information about this service, see Using EC2Config Service in the Microsoft Windows Guide. If you were using an Elastic IP address with the instance, the address is automatically unmapped when the instance stops. While the instance is stopped, you're charged for the address being unmapped (unless you remap it to another instance). When you restart the instance, you need to manually remap the Elastic IP address to the instance; it doesn't happen automatically. For EC2 instances launched into a VPC, the Elastic IP address remains associated with the stopped instance. When you restart the instance, the Elastic IP address is active. While the Elastic IP address is associated with the stopped instance, you will be charged for the Elastic IP address. For more information about the charges for Elastic IP addresses, go to the Amazon EC2 product page. Instance Attributes Each Amazon EBS-backed instance has an attribute called InstanceInitiatedShutdownBehavior that controls whether the instance stops or terminates when you initiate a shutdown from within the instance itself. The default is stop. You can modify the attribute while the instance is running or stopped. For more information, see Changing the Instance Initiated Shutdown Behavior (p. 393). You can modify these instance attributes only while the instance is stopped: Kernel RAM disk Instance type User data
For more information about modifying instance attributes while the instance is stopped, see Modifying Attributes of a Stopped Instance (p. 396). Storage While the instance is stopped, you can treat the root volume like any other volume, and modify it (for example, repair file system problems or update software). You just detach the volume from the stopped instance, attach it to a running instance, make your changes, detach it from the running instance, and then reattach it to the stopped instance. Make sure you reattach it to the correct storage device (whichever device name is specified as the root device in the instance's block device mapping). While the instance is stopped, you can't change anything about the instance's block device mapping except the DeleteOnTermination flag for an attached volume (you can also change the flag while the instance is running). For more information, see Changing the Root Volume to Persist (p. 132).
Instance Termination
When an instance terminates, any instance store associated with that instance is deleted. By default, any volumes that you attach as you launch the instance are automatically deleted when the instance terminates. However, any volumes that you attached to a running instance persist even after the instance terminates. You can change the default behavior using the DeleteOnTermination flag. For an example of how to change this flag when launching an instance, see Using Amazon EC2 Root Device Storage (p. 132). You can see the value for the DeleteOnTermination flag for each of the attached volumes by looking at the instance's block device mapping (for more information, see Viewing the EBS Volumes in an Instance Block Device Mapping (p. 555)).You can't change the flag's value after the instance is launched; however, you can launch the instance with your desired value for the flag. In the launch request, you just specify a block device mapping with the value. For an example of how to change the flag at launch time, see Changing the Root Volume to Persist (p. 132). If you detach and then reattach a volume that was created at instance launch, it's treated like a new volume that you attached after the launch, and its DeleteOnTermination flag is set to false. What happens to the volume when you terminate the instance it's attached to? Assuming the volume's DeleteOnTermination flag is false, the volume persists in its current state.You could take a snapshot of it, and you could attach it to any other instance you have.
Note
When you launch an instance of a particular AMI and then terminate the instance, any remaining volumes are not automatically related to any future instances of that AMI. In other words, a new instance that you launch of that same AMI doesn't attempt to attach to the remaining volume. However, you can manually attach the remaining volume to the new instance if you want. For more information on persisting the data after instance termination, see Data Persistence after Instance Termination (p. 487). Starting with the 2009-10-31 API version, you can prevent an instance from being terminated.This feature is available for both Amazon EC2 instance store-backed and Amazon EBS-backed instances. Each instance has a DisableApiTermination attribute that defaults to false (i.e., the instance can be terminated). You can modify this instance attribute while the instance is running or stopped (in the case of Amazon EBS-backed instances).
Note
If you try to stop an instance that uses an instance store as its root device, you receive an error. When an instance is stopped, it is shut down, and any data stored in RAM is not preserved. You're not billed for hourly usage or data transfer, but you're billed for any Amazon EBS volume storage. You can start the instance at any time with a start request. Each time you transition an instance from stopped to started, we charge a full instance hour, even if transitions happen multiple times within a single hour. For information about the differences between stopping an instance and terminating an instance, see Stopping Instances (p. 384).
Amazon Elastic Compute Cloud User Guide Stopping and Starting Instances
API
To stop and start an instance
1. Construct the following Query request to stop an instance.
https://ec2.amazonaws.com/ ?Action=StopInstances &InstanceId.1=i-10a64379 &AUTHPARAMS
2.
Terminating Instances
This topic describes how to terminate an Amazon EC2 instance. If the instance you launched is not in the free usage tier, 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). When you've decided that you no longer need an instance, you can terminate it. As soon as the status of an instance changes to shutting down or terminated, you stop incurring charges for that instance.
For information about the differences between stopping an instance and terminating an instance, see Stopping Instances (p. 384). For information about preventing an instance from being terminated, see Enabling Termination Protection for an Instance (p. 390). You cannot restart a terminated instance. However, you can launch additional instances of the same AMI.
API
To terminate an instance, use the TerminateInstances command. This example Query terminates the instance with the ID i-10a64379.
https://ec2.amazonaws.com/?Action=TerminateInstances &InstanceId.1=i-10a64379 &AUTHPARAMS
Note
The DisableApiTermination attribute does not protect an instance from being terminated by being shutdown from within the instance when the InstanceInitiatedShutdownBehavior attribute is set for the instance. For more information about the InstanceInitiatedShutdownBehavior attribute, see Changing the Instance Initiated Shutdown Behavior (p. 393).
2.
disableApiTermination
i-87ad5eec
false
You can enable and disable this attribute of an instance as often as you want.
API
By default, termination protection is disabled for an instance at launch time.
For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference.
2.
Amazon Elastic Compute Cloud User Guide Changing the Shutdown Behavior
&DisableApiTermination.Value=true &AUTHPARAMS
You can enable and disable this attribute of an instance as often as you want.
Note
This termination process will occur no matter what the DisableApiTermination attribute is set to. For more information about the DisableApiTermination attribute, see Enabling Termination Protection for an Instance (p. 390).
Caution
When an AMI is created from an instance, the InstanceInitiatedShutdownBehavior attribute for the instance is also stored in the AMI. Any instances created from that AMI will inherit the InstanceInitiatedShutdownBehavior attribute. This can result in instances being inadvertently terminated when they are shut down from within the instance. You cannot change this attribute in the AMI, but you can change it in the launched instance. The best practice is to always set the InstanceInitiatedShutdownBehavior attribute of an instance to stop before creating an AMI from the instance.
API Version 2013-02-01 393
Amazon Elastic Compute Cloud User Guide Changing the Shutdown Behavior
4.
Select either Terminate or Stop from the Shutdown Behavior drop-down list.
Amazon Elastic Compute Cloud User Guide Changing the Shutdown Behavior
5.
You can toggle the attribute between Stop and Terminate as often as you want.
Sample response:
instanceInitiatedShutdownBehavior i-87ad5eec stop
2.
Sample response:
instanceInitiatedShutdownBehavior i-87ad5eec terminate
You can toggle the attribute between stop and terminate as often as you want.
API
To change the InstanceInitiatedShutdownBehavior attribute
1. Call the DescribeInstanceAttribute action to get the current value of the attribute.
Amazon Elastic Compute Cloud User Guide Modifying Attributes of a Stopped Instance
For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference. The following is an example response.
<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/201302-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <instanceId>i-5d7e8e36</instanceId> <instanceInitiatedShutdownBehavior> <value>stop</value> </instanceInitiatedShutdownBehavior> </DescribeInstanceAttributeResponse>
2.
You can toggle the attribute between stop and terminate as often as you want.
Amazon Elastic Compute Cloud User Guide Modifying Attributes of a Stopped Instance
For a list of all the available instance attributes you can change (not just those that require the instance to be stopped), go to ec2-modify-instance-attribute in the Amazon Elastic Compute Cloud Command Line Reference.
Note
Although you can use the AWS Management Console to stop and start instances, and to change the instance type or user data, you can't use it to modify the kernel or RAM disk instance attributes. That functionality is available only through the command line tools or API. For information about kernels and RAM disks, see Kernel FAQ (p. 86).
PROMPT>
PROMPT>
PROMPT>
The following is a sample response from the first command in the preceding list.
kernel i-87ad5eec aki-94c527fd
2.
Choose one of the following commands to modify the value of the attribute of interest.
Amazon Elastic Compute Cloud User Guide Modifying Attributes of a Stopped Instance
PROMPT>
PROMPT>
PROMPT>
When you restart the instance, the new attribute value takes effect.
API
You can modify only a single attribute in each call.
For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference. The following is an example response.
<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/201302-01/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <instanceId>i-5d7e8e36</instanceId> <instanceType> <value>m1.small</value> </instanceType> </DescribeInstanceAttributeResponse>
2.
Issue the following Query request to modify the attribute of interest.The example changes the instance type to c1.medium.
https://ec2.amazonaws.com/ ?Action=ModifyInstanceAttribute &InstanceId=i-87ad5eec &Attribute=instanceType &Value=c1.medium &AUTHPARAMS
Related Topics
Kernel FAQ (p. 86) Instance Types and Architectures FAQ (p. 596) User Data Retrieval (p. 377)
Troubleshooting Instances
Topics Troubleshooting Instances with Failed Status Checks (p. 399) What to Do If an Instance Immediately Terminates (p. 422) Getting Console Output and Rebooting Instances (p. 423) This section provides information to help you troubleshoot problems with your instance.
If a system status check has failed, you can try one of the following options: For an instance using an EBS-backed AMI, stop and re-start the instance. For an instance using an instance-store backed AMI, terminate the instance and launch a replacement. Wait for our systems to resolve the issue. If these steps do not resolve your issue, you can seek assistance by posting your issue to the Developer Forums or contacting Premium Support. If an instance status check has failed, follow these steps: 1. 2. Right-click your instance, and then click Reboot. It may take a few minutes for your system to restart. Verify that the problem still exists; in some cases, rebooting may resolve the problem.
API Version 2013-02-01 399
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
3. 4. 5. 6. 7.
Wait until the instance shows a running state. Right-click the instance and then click Get System Log.You can use this information to help identify the problem. Be sure you have rebooted recently to clear unnecessary information from the log. Review the log that appears on the screen. Use the list of known system log error statements below to troubleshoot your issue. If these steps do not resolve your issue, you can seek assistance by posting your issue to the Developer Forums or contact Premium Support.
If your experience differs from the our check results, or if you are having an issue with your instance that our checks did not detect, click Report an Issue at the bottom of the Status Checks tab to help us improve our detection tests.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
"fsck died with exit status" (Missing device). (p. 416) Operating System Errors GRUB prompt: "grubdom>") (p. 417) "Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring. [FAILED]" (Hardcoded MAC address) (p. 420) "Unable to load SELinux Policy. Machine is in enforcing mode. Halting now. Kernel panic - not syncing: Attempted to kill init!" (SELinux misconfiguration) (p. 421) " XENBUS: Timeout connecting to devices!" ((Xenbus timeout)) (p. 421)
Memory Errors
Out of memory error (OOM): "Out of memory: kill process"
An out of memory error is indicated by a system log entry similar to the one shown below:
[115879.769795] Out of memory: kill process 20273 (httpd) score 1285879 or a child [115879.769795] Killed process 1917 (php-cgi) vsz:467184kB, anonrss:101196kB, file-rss:204kB
Potential Cause
Exhausted memory
Suggested Actions
For this instance type EBS-backed Do this Do one of the following: Stop the instance, and modify the instance to use a different instance type, and start the instance again. For example, you may want to use a larger instance type or a high-memory instance type. Reboot the instance to return it to a non-impaired status. The problem will probably occur again unless you change the instance type.
Instance-store backed
Do one of the following: Relaunch the instance using a different instance type. For example, you may want to use a larger instance type or a high-memory instance type. Reboot the instance to return it to an unimpaired status. The problem will probably occur again unless you change the instance type.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
[H[J
root (hd0) Filesystem type is ext2fs, using whole disk kernel /boot/vmlinuz-2.6.35.14-95.38.amzn1.i686 root=LABEL=/ console=hvc0 LANG= en_US.UTF-8 KEYTABLE=us initrd /boot/initramfs-2.6.35.14-95.38.amzn1.i686.img ERROR: mmu_update failed with rc=-22
Potential Cause
Issue with Amazon Linux.
Suggested Action
Seek assistance by posting your issue to the Developer Forums or contacting Premium Support.
Device Errors
"I/O error, , sector " (Block device failure)
An input/output error is indicated by a system log entry similar to the following example:
[9943662.053217] [9943664.191262] [9943664.191285] [9943664.191297] [9943664.191304] [9943664.191310] [9943664.191317] [9943664.191324] [9943664.191332] [9943664.191339] [9943664.191581] [9943664.191590] [9943664.191597] [9943664.191767] [9943664.191970] [9943664.192143] [9943664.192949] [9943664.193112] [9943664.193266] ... end_request: I/O end_request: I/O Buffer I/O error Buffer I/O error Buffer I/O error Buffer I/O error Buffer I/O error Buffer I/O error Buffer I/O error Buffer I/O error end_request: I/O Buffer I/O error Buffer I/O error end_request: I/O end_request: I/O end_request: I/O end_request: I/O end_request: I/O end_request: I/O error, dev sde, sector error, dev sde, sector on device md0, logical on device md0, logical on device md0, logical on device md0, logical on device md0, logical on device md0, logical on device md0, logical on device md0, logical error, dev sde, sector on device md0, logical on device md0, logical error, dev sde, sector error, dev sde, sector error, dev sde, sector error, dev sde, sector error, dev sde, sector error, dev sde, sector 52428288 52428168 block 209713024 block 209713025 block 209713026 block 209713027 block 209713028 block 209713029 block 209713030 block 209713031 52428280 block 209713136 block 209713137 52428288 52428288 52428288 52428288 52428288 52428288
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Potential Causes
Instance type EBS-backed Instance-store backed Potential cause Failed EBS volume Failed physical drive
Suggested Actions
For this instance type EBS-backed Do this Use one of the following procedures. 1. Stop the instance. 2. Detach the volume. 3. Attempt to recover the volume. 4. Re-attach the volume to the instance. 5. Detach the volume.
Note
Data will not be recovered.
Tip
Its good practice to snapshot your EBS-backed volumes often. This dramatically decreases the risk of data loss as a result of failure.
Instance-store backed
Note
Data will not be recovered. Recover from backups
Tip
Its a good practice to use either Amazon S3 or Amazon EBS volumes for backups. Non-EBS volumes are directly tied to single host and single disk failures.
"IO ERROR: neither local nor remote disk" (Broken distributed block device)
An input/output error on the device is indicated by a system log entry similar to the following example:
... block drbd1: Local IO failed in request_timer_fn. Detaching...
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Aborting journal on device drbd1-8. block drbd1: IO ERROR: neither local nor remote disk Buffer I/O error on device drbd1, logical block 557056 lost page write due to I/O error on drbd1 JBD2: I/O error detected when updating journal superblock for drbd1-8.
Potential Causes
Instance type EBS-backed Instance-store backed Potential cause Failed EBS volume Failed physical drive
Suggested Action
Terminate the instance and launch another instance. For an EBS-backed instance you can recover data from a recent snapshot by creating an image from it. Any data added after the snapshot will not be recovered.
Kernel Errors
"request_module: runaway loop modprobe" (Looping legacy kernel modprobe that applies to older Linux versions, e.g. 2.6.16-xenU)
This condition is indicated by a system log similar to the one shown below. Using an unstable or old Linux kernel can cause an interminable loop condition at startup.
Linux version 2.6.16-xenU (builder@xenbat.amazonsa) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Mon May 28 03:41:49 SAST 2007 BIOS-provided physical RAM map: Xen: 0000000000000000 - 0000000026700000 (usable) 0MB HIGHMEM available. request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Use a newer kernel, either Grub-based or static using one of the two procedures below. Relaunch the instance and specify the kernel and ramdisk parameters.
OR Stop the instance. Modify the kernel and ramdisk attributes to use a newer kernel. Start the instance.
Instance-store backed
Relaunch the instance and specify the kernel and ramdisk parameters.
"FATAL: kernel too old" and "fsck. : No such file or directory while trying to open /dev" (Kernel and AMI mismatch)
This condition is indicated by a system log similar to the one shown below:
Linux version 2.6.16.33-xenU (root@dom0-0-50-45-1-a4-ee.z-2.aes0.internal) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #2 SMP Wed Aug 15 17:27:36 SAST 2007 FATAL: kernel too old Kernel panic - not syncing: Attempted to kill init!
Potential Causes
Incompatible kernel and userland.
Suggested Actions
For this instance type EBS-backed Do this 1. Modify the instance to use a newer kernel. a. Stop the instance. b. Modify the configuration to use a newer kernel. c. Start the instance. 2. Modify the AMI to use a newer kernel.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Do this 1. Modify the instance to use newer kernel. a. Stop the instance. b. Modify the configuration to use a newer kernel. c. Start the instance. 2. Modify the AMI to use a newer kernel.
BusyBox v1.13.3 (Ubuntu 1:1.13.3-1ubuntu5) built-in shell (ash) Enter 'help' for a list of built-in commands. (initramfs)
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Potential Causes
One or more of the following conditions can cause this problem: Missing ramdisk Missing correct modules from ramdisk EBS root volume not correctly attached as /dev/sda1
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Select corrected ramdisk for the EBS volume. 2. Stop the instance. 3. Detach the volume and repair it. 4. Attach the volume to the instance. 5. Start the instance. 6. Modify the AMI to use the corrected ramdisk.
Instance-store backed
Use the following procedure: 1. Terminate the instance and relaunch with correct ramdisk. 2. Rebundle the AMI with the corrected ramdisk definition.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
root (hd0) Filesystem type is ext2fs, using whole disk kernel /vmlinuz.old root=/dev/sda1 ro Error 15: File not found
Potential Causes
One or both of the following conditions can cause this problem: Supplied kernel is not supported by Grub. Fallback kernel does not exist.
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Stop the instance. 2. Replace with working kernel. 3. Install a fallback kernel. 4. Modify the AMI by correcting the kernel.
Instance-store backed
Use the following procedure: 1. Terminate and relaunch the instance with the correct kernel. 2. Rebundle AMI with the corrected kernel definition. 3. (Optional) Seek technical assistance for data recovery using Premium Support.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Xen: 0000000000000000 - 0000000026700000 (usable) 0MB HIGHMEM available. request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c request_module: runaway loop modprobe binfmt-464c
Suggested Actions
For this instance type EBS-backed Do this Use a newer kernel, either Grub-based or static using one of the two procedures below. Relaunch the instance and specify the kernel and ramdisk parameters.
OR Stop the instance. Modify the kernel and ramdisk attributes to use a newer kernel. Start the instance.
Instance-store backed
Relaunch the instance and specify the kernel and ramdisk parameters.
"fsck. : No such file or directory while trying to open /dev" (Filesystem not found)
This condition is indicated by a system log similar to the one shown below:
Welcome to Fedora Press 'I' to enter interactive startup. Setting clock : Wed Oct 26 05:52:05 EDT 2011 [ Starting udev: [ OK ] [ OK ]
OK
No devices found Setting up Logical Volume Management: File descriptor 7 left open No volume groups found [ OK ]
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Checking filesystems Checking all file systems. [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/sda1 /dev/sda1: clean, 82081/1310720 files, 2141116/2621440 blocks [/sbin/fsck.ext3 (1) -- /mnt/dbbackups] fsck.ext3 -a /dev/sdh fsck.ext3: No such file or directory while trying to open /dev/sdh /dev/sdh: The superblock could not be read or does not describe a correct ext2 filesystem. If the device is valid and it really contains an ext2 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> [FAILED]
*** An error occurred during the file system check. *** Dropping you to a shell; the system will reboot *** when you leave the shell. Give root password for maintenance (or type Control-D to continue):
Potential Causes
A bug exists in ramdisk filesystem definitions /etc/fstab Misconfigured filesystem definitions in /etc/fstab Missing/failed drive
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Stop the instance, detach the root volume, repair/modify /etc/fstab the volume, attach the volume to the instance, and start the instance. 2. Fix ramdisk to include modified /etc/fstab (if applicable). 3. Modify the AMI to use a newer ramdisk.
Tip
The sixth field in the fstab defines availability requirements of the mount a non-zero value implies that an fsck will be done on that volume and must succeed. Using this field can be problematic in Amazon EC2 because a failure typically results in an interactive console prompt which is not currently available in Amazon EC2. Use care with this feature and read the Linux man page for fstab. Instance-store backed Use the following procedure: 1. Terminate the instance and relaunch another instance. 2. Detach any errant EBS volumes and the reboot instance. 3. (Optional) Seek technical assistance for data recovery using Premium Support.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
EXT3-fs: mounted filesystem with ordered data mode. Setting up other filesystems. Setting up new root fs no fstab.sys, mounting internal defaults Switching to new root and running init. unmounting old /dev unmounting old /proc unmounting old /sys mountall:/proc: unable to mount: Device or resource busy mountall:/proc/self/mountinfo: No such file or directory mountall: root filesystem isn't mounted init: mountall main process (221) terminated with status 1 General error mounting filesystems. A maintenance shell will now be started. CONTROL-D will terminate this shell and re-try. Press enter for maintenance (or type Control-D to continue):
Potential Causes
Instance type EBS-backed Potential cause Detached or failed EBS volume. Corrupted filesystem. Mismatched ramdisk and AMI combination (e.g., Debian ramdisk with a Suse AMI).
Instance-store backed
Failed drive. Corrupted file system. Mismatched ramdisk and combination (for example, Debian ramdisk with a Suse AMI).
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Stop the instance. 2. Detach the root volume. 3. Attach the root volume to a known working instance. 4. Run filesystem check (fsck a /dev/). 5. Fix any errors. 6. Detach the volume from the known working instance. 7. Attach the volume to the stopped instance. 8. Start the instance. 9. Recheck the instance status.
Instance-store backed
Try one of the following: Restart a new instance. (Optional) Seek technical assistance for data recovery using Premium Support.
"Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block" (Root filesystem mismatch)
This condition is indicated by a system log similar to the one shown below.
Linux version 2.6.16-xenU (builder@xenbat.amazonsa) (gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)) #1 SMP Mon May 28 03:41:49 SAST 2007 Kernel command line: root=/dev/sda1 ro 4 Registering block device major 8 Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1)
Potential Causes
Instance type EBS-backed Potential cause Device not attached correctly. Root device not attached at correct device point. Filesystem not expected format. Use of legacy kernel (e.g., 2.6.16-XenU).
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Do one of the following: Stop and then restart the instance. Modify root volume to attach at the correct device point, possible /dev/sda1 instead of /dev/sda. Stop and modify to use modern kernel.
Instance-store backed
Terminate and relaunch the instance. We strongly recommend using a modern kernel.
"Error: Unable to determine major/minor number of root device" or "[ramfs /]#" (Root filesystem/device mismatch)
This condition is indicated by a system log similar to the one shown below.
... XENBUS: Device with no driver: device/vif/0 XENBUS: Device with no driver: device/vbd/2048 drivers/rtc/hctosys.c: unable to open rtc device (rtc0) Initializing network drop monitor service Freeing unused kernel memory: 508k freed :: Starting udevd... done. :: Running Hook [udev] :: Triggering uevents...<30>udevd[65]: starting version 173 done. Waiting 10 seconds for device /dev/xvda1 ... Root device '/dev/xvda1' doesn't exist. Attempting to create it. ERROR: Unable to determine major/minor number of root device '/dev/xvda1'. You are being dropped to a recovery shell Type 'exit' to try and continue booting sh: can't access tty; job control turned off [ramfs /]#
Potential Causes
Missing or incorrectly configured virtual block device driver Device enumeration clash (sda versus xvda or sda instead of sda1) Incorrect choice of DomU kernel
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Stop the instance. 2. Detach the volume. 3. Fix the device mapping problem. 4. Start the instance. 5. Modify the AMI to address device mapping issues.
Instance-store backed
Use the following procedure: 1. Rebundle with the appropriate fix (map block device correctly). 2. Terminate and relaunch the instance.
Potential Causes
Missing or incorrectly configured virtual block device driver Device enumeration clash (sda versus xvda) Incorrect choice of DomU kernel
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Stop the instance. 2. Detach the volume. 3. Fix the device mapping problem. 4. Start the instance. 5. Modify the AMI to address device mapping issues.
Instance-store backed
Use the following procedure: 1. Rebundle with the appropriate fix (map block device correctly). 2. Terminate and relaunch the instance.
Filesystem check required: " days without being checked, check forced."
This condition is indicated by a system log similar to the one shown below.
... Checking filesystems Checking all file systems. [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/sda1 /dev/sda1 has gone 361 days without being checked, check forced
Potential Causes
Filesystem check time passed; a filesystem check is being forced.
Suggested Actions
Wait until the filesystem check completes. Note that a filesystem check can take a long time depending on the size of the root filesystem. Modify your filesystems to remove the filesystem check (fsck) enforcement using tune2fs or tools appropriate for your filesystem.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
/sbin/fsck.xfs: /dev/sdh does not exist fsck died with exit status 8 [31mfailed (code 8).[39;49m
Potential Causes
Ramdisk looking for missing drive Filesystem consistency check forced Drive failed or detached
Suggested Actions
For this instance type EBS-backed Do this Try one or more of the following to resolve the issue: Stop the instance, attach volume to existing running instance. Manually run consistency checks. Fix ramdisk to include relevant utilities. Modify filesystem tuning parameters to remove consistency requirements (not recommended).
Instance-store backed
Try one or more of the following to resolve the issue: Rebundle ramdisk with correct tooling. Modify filesystem tuning parameters to remove consistency requirements (not recommended). Terminate and restart. (Optional) Seek technical assistance for data recovery using Premium Support.
[ Minimal BASH-like line editing is supported. the first word, TAB lists possible
command
completions.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Potential Causes
Instance type EBS-backed Potential causes Missing grub.conf file. Incorrect Grub image used expecting grub.conf at different location. Unsupported filesystem used to store grub.conf.
Instance-store backed
Missing grub.conf file. Incorrect Grub image used expecting grub.conf at different location.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
Suggested Actions
For this instance type EBS-backed Do this Use one of the following procedures: Modify the AMI and relaunch the instance 1. Modify the source AMI to create a grub.conf at the standard location (/boot/grub/menu.lst). 2. Pick the appropriate Grub image, (hd0-1st drive or hd00 1st drive, 1st partition). 3. Relaunch the instance.
OR Fix the existing instance 1. Stop the instance. 2. Detach the root filesystem. 3. Attach the root filesystem to a known working instance. 4. Mount filesystem. 5. Create grub.conf. 6. Detach filesystem. 7. Attach to the original instance. 8. Modify kernel attribute to use appropriate Grub (1st disk or 1st partition on 1st disk). 9. Start the instance.
Instance-store backed
Option 1: Modify the AMI and relaunch the instance 1. Modify the source AMI to create a grub.conf at the standard location (/boot/grub/menu.lst). 2. Pick the appropriate Grub image, (hd0-1st drive or hd00 1st drive, 1st partition). 3. Relaunch the instance.
Option 2: Fix the existing instance Relaunch the instance using the correct kernel if you believe the kernel was incorrect.
Note
To recover data from the existing instance, contact AWS Premium Support.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
"Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring. [FAILED]" (Hardcoded MAC address)
This condition is indicated by a system log similar to the one shown below:
... Bringing up loopback interface: Bringing up interface eth0: ignoring. [FAILED] Starting auditd: [ OK ]
OK
Potential Causes
There is a hardcoded interface MAC in the AMI configuration.
Suggested Actions
For this instance type EBS-backed Do this Do one of the following: Modify the AMI to remove the hard coding and relaunch the instance.
OR 1. Stop the instance. 2. Detach the root file system. 3. Modify the instance to remove the hard coded MAC address. 4. Attach the volume to original instance. 5. Start the instance.
Instance-store backed
Do one of the following: Modify the instance to remove the hard coded MAC address. Relaunch the instance.
Amazon Elastic Compute Cloud User Guide Instances with Failed Status Checks
"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now. Kernel panic - not syncing: Attempted to kill init!" (SELinux misconfiguration)
This condition is indicated by a system log similar to the one shown below.
audit(1313445102.626:2): enforcing=1 old_enforcing=0 auid=4294967295 Unable to load SELinux Policy. Machine is in enforcing mode. Halting now. Kernel panic - not syncing: Attempted to kill init!
Potential Causes
SELinux has been enabled in error: Supplied kernel is not supported by Grub. Fallback kernel does not exist.
Suggested Actions
For this instance type EBS-backed Do this Use the following procedure: 1. Stop the instance. 2. Detach the volume. 3. Disable SELinux. 4. Start the instance.
Instance-store backed
Use the following procedure: 1. Terminate and relaunch the instance. 2. (Optional) Seek technical assistance for data recovery using Premium Support.
Potential Causes
The block device not is connected to the instance. This instance is using a very old DomU kernel.
Amazon Elastic Compute Cloud User Guide What to Do If an Instance Immediately Terminates
Suggested Actions
For this instance type EBS-backed Do this Do one of the following: Modify AMI and instance to use a modern kernel and relaunch the instance. Reboot the instance.
Instance-store backed
Do one of the following: Reboot the instance. Modify AMI and instance to use a modern kernel and relaunch the instance.
Amazon Elastic Compute Cloud User Guide Getting Console Output and Rebooting Instances
PROMPT>
ec2-describe-instances instance_id -v
2.
When you use verbose mode, the response includes the underlying SOAP request and the SOAP XML response. In the XML response that's displayed, locate the stateReason element. It looks similar to the following example.
<stateReason> <code>Client.UserInitiatedShutdown</code> <message>Client.UserInitiatedShutdown: User initiated shutdown</message> </stateReason>
The preceding example shows what's displayed for a normal instance that you've stopped. For the instance that terminated immediately, the code and message elements will describe the reason for the termination (e.g., VolumeLimitExceeded).
API
To get information about why the instance terminated
1. Construct the following Query request. For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference.
https://ec2.amazonaws.com/ ?Action=DescribeInstances &AUTHPARAMS
2.
In the XML response that's displayed, locate the stateReason element. It looks similar to the following example.
<stateReason> <code>Client.UserInitiatedShutdown</code> <message>Client.UserInitiatedShutdown: User initiated shutdown</message> </stateReason>
The preceding example shows what's displayed for a normal instance that you've stopped. For the instance that terminated immediately, the code and message elements will describe the reason for the termination (e.g., VolumeLimitExceeded).
Amazon Elastic Compute Cloud User Guide Getting Console Output and Rebooting Instances
Console Output
For Linux/UNIX instances, the Amazon EC2 instance console output displays the exact console output that would normally be displayed on a physical monitor attached to a machine. This output is buffered because the instance produces it and then posts it to a store where the instance's owner can retrieve it. For Windows instances, the Amazon EC2 instance console output displays the last three system event log errors. The posted output is not continuously updated; only when it is likely to be of the most value. This includes shortly after instance boot, after reboot, and when the instance terminates.
Note
Only the most recent 64 KB of posted output is stored, which is available for at least 1 hour after the last posting. You can retrieve the console output for an instance using GetConsoleOutput. For more information, go to the Amazon Elastic Compute Cloud API Reference or Amazon Elastic Compute Cloud Command Line Reference.
Note
Only the instance owner can access the console output.
Instance Reboot
Just as you can reset a computer by pressing the reset button, you can reset Amazon EC2 instances using RebootInstances. For more information, go to the Amazon Elastic Compute Cloud API Reference or Amazon Elastic Compute Cloud Command Line Reference.
Caution
For Windows instances, this operation performs a hard reboot that might result in data corruption.
Important
For information about Amazon VPC security groups, go to Security Groups in the Amazon Virtual Private Cloud User Guide.
When you create a new security group, you must provide a friendly name and a description of the group. AWS assigns each group a unique ID, in the form sg-xxxxxxxx. These are the initial settings for a new group that you create: Allow no inbound traffic Allow all outbound traffic After you've created a security group, you can change its rules to reflect the type of inbound traffic that you want to reach the associated instances. You can change only the inbound rules; you can't modify the outbound rules for an EC2 security group. If you want to allow the instances associated with a security group to talk to each other, you must explicitly add rules.
Note
In Amazon EC2, you can create up to 500 security groups in each region for each account, with up to 100 rules per security group. In Amazon VPC, you can have up to 100 security groups, with up to 50 rules per security group, in each VPC. The security groups for Amazon VPC do not count against the security group limit for Amazon EC2.
You can't modify an existing rule in a group. However, you can add and remove rules to a group at any time.Your changes are automatically applied to instances associated with the security group after a short period.
Caution
Because an Amazon EC2 instance can belong to multiple security groups, more than 100 rules can apply to an instance. Associating hundreds of rules with an instance might cause problems when you access the instance. We recommend you condense your rules as much as possible.
10.10.1.32 = 00001010.00001010.00000001.00100000 First 27 bits== 00001010.00001010.00000001.001 10.10.1.44 matches 10.10.1.32/27 = 00001010.00001010.00000001.00101100 But 10.10.1.90 doesnt match 10.10.1.32/27 = 00001010.00001010.00000001.01011010
Amazon Elastic Compute Cloud User Guide API and Command Overview
Description Creates a new security group for use with your account. Adds one or more rules to a security group.
Returns information about security groups associated with your account. Removes one or more rules from a security group.
Note
VPC security groups have additional API actions and commands that apply to them. For more information, go to Security Groups in the Amazon Virtual Private Cloud User Guide.
API
Construct a Query request similar to the following example to create a security group.
https://ec2.amazonaws.com/ ?Action=CreateSecurityGroup &GroupName=security-group-name &GroupDescription=security-group-description &...auth parameters...
80
80
FROM
Tip
You can filter this list to return only certain security groups of interest to you. For more information about how to filter the results, go to ec2-describe-group in the Amazon Elastic Compute Cloud Command Line Reference.
API
Construct the following Query request to view your security groups.
https://ec2.amazonaws.com/ ?Action=DescribeSecurityGroups &GroupName.1=security-group-name &...auth parameters...
Tip
You can filter this list to return only certain security groups of interest to you. For more information about how to filter the results, go to DescribeSecurityGroups in the Amazon Elastic Compute Cloud API Reference.
Amazon Elastic Compute Cloud User Guide Adding a Security Group Rule
Note
After an EC2 instance is launched, you can't change which EC2 security groups it belongs to. Exception: If you're using Amazon VPC, you can change which VPC security groups a VPC instance is in after launch. For more information, go to Security Groups in the Amazon Virtual Private Cloud User Guide.
4.
To add a rule: a. b. c. From the Create a new rule: drop-down list, select the option you want. Specify a port or port range (if you've chosen a custom protocol rule). In the Source field, specify one of the following: Name or ID of a security group (to allow access from that group). If the group isn't in your AWS account, prefix the group name with the AWS account ID and a forward slash (e.g., 111122223333/OtherSecurityGroup). IP address range in CIDR notation (to allow access from that IP address range). For example, enter 0.0.0.0/0 to allow all IP addresses to access the specified port range. Enter an IP address or range of addresses to limit access to one computer or a network, for example 203.0.113.5/32.
Amazon Elastic Compute Cloud User Guide Adding a Security Group Rule
5. 6.
Click Add Rule. An asterisk appears on the Inbound tab. Click Apply Rule Changes. The new rule is created and applied to all instances that belong to the security group.
For example, to modify the default security group to allow port 80 access from all IP addresses:
PROMPT> ec2-authorize default -p 80
ALLOWS
tcp
80
80
FROM
CIDR
For example, to modify the default security group to allow SSH access from your own system's IP address:
PROMPT> ec2-authorize -p 22 -s <your_ip_address>/32
ALLOWS
tcp
22
22
FROM
CIDR
API
Construct a Query request similar to the following to add a rule to a security group.
https://ec2.amazonaws.com/ ?Action=AuthorizeSecurityGroupIngress &IpPermissions.1.IpProtocol=tcp &IpPermissions.1.FromPort=80 &IpPermissions.1.ToPort=80 &IpPermissions.1.IpRanges.1.CidrIp=0.0.0.0/0 &...auth parameters...
Amazon Elastic Compute Cloud User Guide Deleting a Security Group Rule
<return>true</return> </AuthorizeSecurityGroupIngressResponse>
For example, to modify the default security group to remove port 80 access from all IP addresses:
PROMPT> ec2-revoke default -p 80
ALLOWS
tcp
80
80
FROM
CIDR
You can confirm the rule has been deleted by describing the security group by using the ec2-describe-group command.
API
Construct a Query request similar to the following to delete a security group rule.
https://ec2.amazonaws.com/ ?Action=RevokeSecurityGroupIngress &IpPermissions.1.IpProtocol=tcp &IpPermissions.1.FromPort=80 &IpPermissions.1.ToPort=80 &IpPermissions.1.IpRanges.1CidrIp=0.0.0.0/0 &...auth parameters...
API
Construct the following Query request to delete a security group.
https://ec2.amazonaws.com/ ?Action=DeleteSecurityGroup &GroupName=security-group-name &...auth parameters...
Examples
This section provides examples of configuring EC2 security groups using the command line tools.
Note
In addition to these examples, you can maintain your own firewall on any of your instances. This can be useful if you have specific requirements not met by the Amazon EC2 distributed firewall.
Albert, who is a cautious type, checks the access rules of the default group.
PROMPT> ec2-describe-group default GROUP sg-2eac845a 111122223333 default default group PERMISSION 111122223333 default ALLOWS icmp -1 -1 FROM USER 111122223333 NAME default ID sg-2eac845a ingress PERMISSION 111122223333 default ALLOWS tcp 0 65535 FROM USER 111122223333 NAME default ID sg-2eac845a ingress PERMISSION 111122223333 default ALLOWS udp 0 65535 FROM USER 111122223333 NAME default ID sg-2eac845a ingress
Albert notices that it only accepts ingress network connections from other members of the default group for all available protocols (TCP, UDP, ICMP) and ports. 3 Albert, being cautious, uses the Linux/UNIX nmap command to port scan his instance.
$ nmap -P0 -p1-100 ec2-203-0-113-5.compute-1.amazonaws.com Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-03-30 15:06 SAST All 100 scanned ports on ec2-203-0-113-5.compute-1.amazonaws.com (203.0.113.5) are: filtered Nmap finished: 1 IP address (1 host up) scanned in 31.008 seconds
Albert decides he should be able to SSH into his instance, but only from his own computer.
PROMPT> ec2-authorize default -P tcp -p 22 -s 203.0.113.7/32 GROUP sg-2eac845a PERMISSION ALLOWS tcp 22 22 FROM CIDR 203.0.113.7/32 ingress
Albert is happy.
ami-fba54092, her application tier executing in twenty instances of ami-e3a5408a,and her multi-master database in two instances of ami-f1a54098. She's concerned about the security of her subscriber database, so she wants to restrict network access to her middle and back tier machines. When the traffic to her site increases over the holiday shopping period, she adds additional instances to her web and application tiers to handle the extra load.
Launch Process
1 First, Mary creates a group for her Apache web server instances and allows HTTP access to the world.
PROMPT> ec2-create-group apache -d "Mary's Apache group" GROUP sg-ed5b6c99 apache Mary's Apache group PROMPT> ec2-describe-group apache GROUP sg-ed5b6c99 111122223333
apache
PROMPT> ec2-authorize apache -P tcp -p 80 -s 0.0.0.0/0 GROUP sg-ed5b6c99 PERMISSION 111122223333 apache ALLOWS tcp 80 80 CIDR 0.0.0.0/0 ingress PROMPT> ec2-describe-group apache GROUP sg-ed5b6c99 111122223333 PERMISSION 111122223333 apache CIDR 0.0.0.0/0 ingress
FROM
Mary launches seven instances of her web server AMI as members of the apache group.
PROMPT> ec2-run-instances ami-fba54092 -n 7 -g apache RESERVATION r-0592776c 111122223333 apache INSTANCE i-cfd732a6 ami-fba54092 pending 0 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99 INSTANCE i-cfd732a7 ami-fba54092 pending 1 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99 INSTANCE i-cfd732a8 ami-fba54092 pending 2 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99 INSTANCE i-cfd732a9 ami-fba54092 pending 3 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99 INSTANCE i-cfd732aa ami-fba54092 pending 4 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99 INSTANCE i-cfd732ab ami-fba54092 pending 5 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99 INSTANCE i-cfd732ac ami-fba54092 pending 6 m1.small 2010-0319T13:59:03+0000 us-east-1a aki-94c527fd ari-96c527ff monitoringdisabled ebs paravirtual xen sg-ed5b6c99
PROMPT> ec2-describe-instances i-cfd732a6 RESERVATION r-0592776c 111122223333 apache INSTANCE i-cfd732a6 ami-fba54092 ec2-203-0-11312.compute-1.amazonaws.com running 0 m1.small 2010-03-30T08:43:48+0000 us-east-1a aki-94c527fd ari-96c527ff monitoring-disabled 203.0.113.12 10.254.137.191 ebs paravirtual xen sg-ed5b6c99 BLOCKDEVICE /dev/sda1 vol-cf13b3a6 2010-0330T08:01:44.000Z
Being as cautious as Albert, Mary uses the Linux/UNIX nmap command to confirm the permissions she just configured.
$ nmap -P0 -p1-100 ec2-203-0-113-12.compute-1.amazonaws.com Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-03-30 15:10 SAST Interesting ports on ec2-203-0-113-12.compute-1.amazonaws.com (203.0.113.12): (The 99 ports scanned but not shown are in state: filtered) PORT STATE SERVICE 80/tcp open http Nmap finished: 1 IP address (1 host up) scanned in 33.409 seconds
Mary can reach her web server. 5 Mary creates a separate group for her application server.
PROMPT> ec2-create-group appserver -d "Mary's app server" GROUP sg-e95b6c9d appserver Mary's app server
Mary grants network access between her web server group and the application server group.
PROMPT> ec2-authorize appserver -o apache -u 111122223333 GROUP appserver PERMISSION appserver ALLOWS tcp 0 FROM USER 111122223333 GRPNAME apache PERMISSION appserver ALLOWS udp 0 FROM USER 111122223333 GRPNAME apache PERMISSION appserver ALLOWS icmp -1 FROM USER 111122223333 GRPNAME apache
Mary verifies access to her app server is restricted by port scanning one of the application servers using the Linux and UNIX nmap command.
$ nmap -P0 -p1-100 ec2-203-0-113-9.compute-1.amazonaws.com Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2010-03-30 15:11 SAST All 100 scanned ports on ec2-203-0-113-9.compute-1.amazonaws.com (203.0.113.9) are: filtered Nmap finished: 1 IP address (1 host up) scanned in 31.008 seconds
Mary confirms that her web servers have access to her application servers. A. She (temporarily) grants SSH access from her workstation to the web server group:
PROMPT> ec2-authorize apache -P tcp -p 22 -s 203.0.113.19/32
B. She logs in to one of her web servers and connects to an application server on TCP port 8080.
$ telnet ec2-203-0-113-9.compute-1.amazonaws.com 8080 Trying 203.0.113.9... Connected to ec2-203-0-113-9.compute-1.amazonaws.com (203.0.113.9). Escape character is '^]'
C. Satisfied with the setup, she revokes SSH access to the web server group.
PROMPT> ec2-revoke apache -P tcp -p 22 -s 203.0.113.19/32
10
Mary repeats these steps to create the database server group and to grant access between the application server and database server groups.
Note
We also provide AWS Multi-Factor Authentication, which requires a physical device and passcode to login to your AWS account. For more information, go to http://aws.amazon.com/mfa.
Query API
Launching and administering Amazon EC2 instances through the Query API requires the access key ID and secret access key. For more information, see How to Get Your Access Key ID and Secret Access Key (p. 444).
Amazon Elastic Compute Cloud User Guide How to Log In with Your Amazon Login and Password
Amazon EC2 key pairEnables you to connect to Linux/UNIX instances through SSH. For more information, see SSH Key Pair (p. 445). Windows administrator password (Windows only)Provides the "first-use" password that enables you to connect to a Windows instance through Remote Desktop. For more information, see Windows Administrator Password (p. 445).
To log in with your login and password (if you have an existing account)
1. Go to the AWS Management Console. 2. Enter your email address, select I am a returning user and my password is, enter your password, and click the Sign In button.
To get a new Amazon login and password (create a new AWS account)
1. Go to the Amazon Web Services web site at http://aws.amazon.com. 2. Click Sign Up Now. 3. Select I am a new user and click the Sign In button. 4. Follow the on-screen prompts to create a new account.
Note
It is important to keep your Amazon login and password secret as they can be used to view and create new credentials. As an increased security measure, we offer Multi-Factor Authentication, which uses the combination of a physical device and passcode to login to your AWS account. For more information, go to http://aws.amazon.com/mfa.
Amazon Elastic Compute Cloud User Guide How to Get Your Access Key ID and Secret Access Key
Note
If you already have two certificates, you won't see the Create a new Certificate option. If you want to create a new certificate, delete one of your existing certificates, after ensuring you are not using it. When the deletion is complete, you see the Create a new Certificate option, which indicates that you can create an additional certificate. The new certificate is created and appears in the X.509 Certificate list. You are prompted to download the certificate and private key files. 5. Create a .ec2 directory in your home directory, and save these files to it with the filenames offered by your browser. You should end up with a PEM-encoded X.509 certificate and a private key file.
For information about how to share AMIs, see Sharing AMIs Safely (p. 61). For information about how to share snapshots, see Modifying Snapshot Permissions (p. 528).
Note
Your account ID number is not a secret. When you grant access to resources, be sure to specify the account ID without the hyphens.
Related Topics
Launching Amazon EC2 Instances (p. 274) Connecting to Amazon EC2 Instances (p. 282)
Amazon Elastic Compute Cloud User Guide AWS Identity and Access Management
This sharing works at the AWS Account level only; you can't restrict access only to specific users within the AWS Account you're sharing, or only to specific users in your own AWS Account. All users in the AWS Account you're sharing with can use the AMI or snapshot you've shared.
Note
Don't be confused by the fact that the attribute for specifying the AWS Account to share with is called UserId. The value you specify for UserId is an AWS Account ID.
Amazon Elastic Compute Cloud User Guide Identity and Access Management
For information on modifying attributes on an AMI, see Sharing AMIs (p. 65). For information on modifying attributes on a snapshot, see Modifying Snapshot Permissions (p. 528)
Amazon EC2 Permissions and AWS Identity and Access Management (IAM)
Using IAM with Amazon EC2 doesn't change how you use the Amazon EC2 API to share AMIs and snapshots with other AWS Accounts. However, you can use IAM policies to specify which Amazon EC2 actions a user in your AWS Account can use with EC2 resources in general.You can't specify a particular Amazon EC2 resource in the policy (e.g,. a specific AMI). Instead, you must specify * as the resource to indicate all resources in the AWS Account.
Important
Amazon EC2 uses SSH keys, Windows passwords, and security groups to control who has access to specific Amazon EC2 instances.You can't use the IAM system to allow or deny access to a specific instance.
Amazon Elastic Compute Cloud User Guide Identity and Access Management
For examples of IAM policies that cover Amazon EC2 actions, see Example Policies for Amazon EC2 (p. 449). For more information about granting permissions to AMIs and snapshots, refer to the topics about the ModifyImageAttribute and ModifySnapshotAttribute APIs in the Amazon Elastic Compute Cloud API Reference.
Amazon Elastic Compute Cloud User Guide Using Temporary Security Credentials
Note
In the future, Amazon EC2 might add new actions that should logically be included in one of the following policies, based on the policys stated goals.
Example 1: Allow a group to only be able to describe, run, stop, start, and terminate instances
In this example, we create a policy that gives access to the relevant actions and attach it to the group. The resource is stated as "*", because you can't specify a particular Amazon EC2 resource in an IAM policy.
{ "Statement":[{ "Effect":"Allow", "Action":["ec2:DescribeInstances","ec2:RunInstances", "ec2:StopInstances","ec2:StartInstances", "ec2:TerminateInstances"], "Resource":"*" } ] }
Example 2: Allow managers to only be able to list the current Amazon EC2 resources in the AWS Account
In this example, we create a policy that lets managers use the Amazon EC2 actions with Describe in the name.
{ "Statement":[{ "Effect":"Allow", "Action":"ec2:Describe*", "Resource":"*" } ] }
Amazon Elastic Compute Cloud User Guide Using IAM Roles with Amazon EC2 Instances
for your system who do not have AWS accounts; these users are called federated users. Additionally, "users" can also be applications that you create to access your AWS resources. You can use these temporary security credentials in making requests to Amazon EC2. The API libraries compute the necessary signature value using those credentials to authenticate your request. If you send requests using expired credentials Amazon EC2 denies the request. For more information about IAM support for temporary security credentials, go to Granting Temporary Access to Your AWS Resources in Using IAM.
https://ec2.amazonaws.com/?Action=DescribeInstances &InstanceId.0=I-45fa2e72 &Signature=Dqlp3Sd6ljTUA9Uf6SGtEExwUQEXAMPLE &SignatureVersion=2 &SignatureMethod=HmacSHA256 &Timestamp=2010-03-31T12%3A00%3A00.000Z &SecurityToken=Security Token Value &AWSAccessKeyId=Access Key ID provided by AWS Security Token Service
Amazon Elastic Compute Cloud User Guide Using IAM Roles with Amazon EC2 Instances
Warning
If you are using services that use instance metadata service (IMDS) with IAM roles, you should ensure that you do not expose your credentials when the services make HTTP calls on your behalf. You should either include logic to ensure that these services cannot leak information from IMDS, or you should have the appropriate firewall rules in place so that the services cannot access IMDS. Types of services that could expose your credentials include: HTTP proxies HTML/CSS validator services XML processors that support XML inclusion
Note
After you create an IAM role or instance profile, it may take several seconds for the appropriate permissions to propagate. If your first attempt to launch an EC2 instance with a role fails, you may need to wait a few seconds before trying again. To troubleshoot issues when using IAM roles with EC2 instances, see Troubleshooting Working with Roles in Using IAM.
To launch an EC2 instance with an IAM role using the AWS Management Console
1. 2. 3. Create an IAM role. For more information, see Creating a Role in Using IAM. Launch an instance with the IAM role. For more information, see Launching an Instance from an AMI (p. 274). Sign AWS requests with the AWS security credentials made available on the EC2 instance. The security credentials that are made available from instance metadata are temporary security credentials. For information on using temporary security credentials, see Using Temporary Security Credentials (p. 449). This is handled for you if you develop your application with the AWS SDK. If you are not using the AWS SDK, then you need to programmatically retrieve the AWS security credentials to sign your service API requests for AWS. The following example shows AWS security credentials returned for an IAM role named s3access.
GET http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access; echo { "Code" : "Success", "LastUpdated" : "2012-04-26T16:39:16Z", "Type" : "AWS-HMAC", "AccessKeyId" : "AKIAIOSFODNN7EXAMPLE...", "SecretAccessKey" : "UtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY...", "Token" : "...", "Expiration" : "2012-04-26T22:39:16Z" }
Amazon Elastic Compute Cloud User Guide Using IAM Roles with Amazon EC2 Instances
To launch an EC2 instance with an IAM role using the IAM and EC2 CLIs
You can use the IAM and EC2 CLIs to create a role, add a policy to the role, create an associated instance profile, and then launch an instance with that instance profile. 1. Create an IAM role, add a policy to it, and create an associated IAM instance profile. The following example shows the creation of an IAM role named s3access with a policy that allow the role to access an S3 bucket, and the creation of an instance profile named s3access. For more information about using the IAM CLI, see iam-rolecreate, iam-roleaddpolicy, and iam-instanceprofilecreate in the AWS Identity and Access Management (IAM) Command Line Reference.
$ iam-rolecreate -r s3access -s ec2.amazonaws.com $ iam-roleaddpolicy -r s3access -e Allow -a s3:\* -c \* -p s3star -o {"Version":"2008-10-17","Statement":[{"Effect":"Allow","Action":["s3:*"],"Re source":["*"]}]} $ iam-instanceprofilecreate -s s3access -r s3access arn:aws:iam::111111111111:instance-profile/s3access
2.
Launch an EC2 instance using the instance profile. The following example shows a t1.micro instance being launched with the instance profile created in step 1. For more information about using the EC2 CLI, see ec2-run-instances and ec2-describe-instances in the Amazon Elastic Compute Cloud Command Line Reference.
$ ec2-run-instances -t t1.micro -p arn:aws:iam::111111111111:instance-profile/s3access -k key-pair -g 'Web Server' ami-e565ba8c RESERVATION r-11c62773 111111111111 sg-e7ddc68e INSTANCE pending key-pair disabled i-9a6843fd us-east-1e ami-e565ba8c aki-88aa75e1
$ ec2-describe-instances RESERVATION r-11c62773 111111111111 sg-e7ddc68e INSTANCE i-9a6843fd ami-e565ba8c ec2-50-19-200-155.compute-1.amazonaws.com ip-10-2828-186.ec2.internal running key-pair 0 t1.micro 2012-0426T16:29:25.000Z us-east-1e aki-88aa75e1 disabled AIPAJ6OQOSP4IRHXCI6E4
3.
Sign service requests with the AWS security credentials made available on the EC2 instance. The security credentials that are made available from instance metadata are temporary security credentials. For information on using temporary security credentials, see Using Temporary Security Credentials (p. 449). This is handled for you if you develop your application with the AWS SDK. If you are not using the AWS SDK, then you need to programmatically retrieve the AWS security credentials to sign your service API requests. The following example shows AWS security credentials returned for an IAM role named s3access.
API Version 2013-02-01 452
Amazon Elastic Compute Cloud User Guide Using IAM Roles with Amazon EC2 Instances
GET http://169.254.169.254/latest/meta-data/iam/security-credentials/s3access; echo { "Code" : "Success", "LastUpdated" : "2012-04-26T16:39:16Z", "Type" : "AWS-HMAC", "AccessKeyId" : "AKIAIOSFODNN7EXAMPLE...", "SecretAccessKey" : "UtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY...", "Token" : "...", "Expiration" : "2012-04-26T22:39:16Z" }
Your instance launched in a default r uoY subnet receives a public IP address. eats i cn n t 'no sd e e ie r vc e a ci lb u p P I .s rd sd ea
Amazon Elastic Compute Cloud User Guide Differences Between EC2-Classic and EC2-VPC
EC2-Classic
Default VPC
t lae ufd n N o CP V
Your instance receives a private IP Your instance receives a static privater uoY address from the EC2-Classic, default IP address from the address range ofeats i cn n VPC range each time it's started. your default VPC. s ier ec ve a ci tats eta i r vp P I serda s d mr f o eh t serda s d en r ga f o r uoy . CV P
Multiple IP addresses You can assign a single IP address to You can assign multiple IP addressesu o Y your instance. to your instance. na c n isa g s elpi tm lu P I ssed esrd a o t r uoy .ctsi en n a Elastic IP address An EIP is disassociated from your instance when you stop it. An EIP remains associated with your n A instance when you stop it. PIE s im n ar e dt ics ea o s a h t iw r uoy eats i cn n nehw uo y po t s .ti DNS hostnames are enabled by default. N D S sntsh mo e a era dlb id ea s y b . t luf ae d
DNS hostnames
EC2-Classic A security group can reference security groups that belong to other AWS accounts.
Default VPC
t lae ufd n N o CP V
A security group can reference security A groups for your VPC only. yt i rc u e s p org u na c er f r c ee n e yt i rc u e s su rg po ro f r uoy CP V . yln o You can change the security group ofu o Y your running instance. na c enh ga c eh t yt i rc u e s p org u f o r uoy g in r nn u .ctsi en n a You can add rules for inbound and outbound traffic. uoY na c dda s lur e ro f dub i non dna do tu nb o u .ifat c fr
Tenancy
You can run your instance on shared u o Y hardware or single-tenant hardware. n a c nu r r uoy eats i cn n n o d ras eh erara wh d r o ee is n-n ag tt l .ewa rdh ar
Amazon Virtual Private Cloud Getting Started Guide Provides a hands-on introduction to Amazon VPC.
Guide Amazon Virtual Private Cloud User Guide Amazon Virtual Private Cloud Network Administrator Guide
Description Provides detailed information about how to use Amazon VPC. Helps network administrators configure your customer gateway.
Amazon Elastic Compute Cloud User Guide Differences Between EC2-Classic and Amazon EC2-VPC
When you launch an instance in EC2-Classic or a default VPC, we allocate a public IP address for the instance. Public IP addresses are reachable from the Internet. A public IP address is associated with an instance until it is stopped or terminated. If you require a persistent public IP address that can be assigned to and removed from instances as necessary, use an Elastic IP address. For more information, see Elastic IP Addresses (EIP) (p. 466). We don't allocate a public IP address for an instance that you launch in a nondefault VPC. Therefore, if you want an instance in a nondefault VPC to communicate with the Internet, you must associate an Elastic IP address with the primary or any secondary private IP address assigned to the network interface for the instance. We provide each instance that has a public IP address with an external DNS hostname. We resolve an external DNS hostname to the public IP address of the instance outside the network of the instance, and to the private IP address of the instance from within the network of the instance. If your instance is in a VPC and you assign it an Elastic IP address, it receives a DNS hostname if DNS hostnames are enabled. For more information, see Using DNS with Your VPC in the Amazon Virtual Private Cloud User Guide. The private IP address and public IP address for an instance are directly mapped to each other through network address translation (NAT). For more information about NAT, go to RFC 1631: The IP Network Address Translator (NAT).
Note
Instances that access other instances through their public NAT IP address are charged for regional or Internet data transfer, depending on whether the instances are in the same region.
Your instance launched in a default r uoY subnet receives a public IP address. eats i cn n t 'no sd e e ie r vc e a ci lb u p P I .s rd sd ea
Amazon Elastic Compute Cloud User Guide Differences Between EC2-Classic and Amazon EC2-VPC
EC2-Classic Your instance receives a private IP address from the EC2-Classic range each time it's started.
Default VPC
tu lN a f o n d e CP V
Your instance receives a static privater uoY IP address from the address range ofeats i cn n your default VPC. s ier ec ve a ci tats eta i r vp P I serda s d mr f o eh t serda s d en r ga f o r uoy . CV P uoY na c n isa g s elpi tm lu eta i r vp P I ssed esrd a o t r uoy .ctsi en n a
Multiple IP addresses We select a single private IP address You can assign multiple private IP for your instance. addresses to your instance.
Network interfaces
IP addresses are associated with the instance; network interfaces aren't supported.
IP addresses are associated with a P I network interface. Each instance has ssed esrd a one or more network interfaces. era dt ics ea o s a h t iw a krote wn . fe i ern at c hcaE eats i cn n s ah eno r o ero m krote wn .cei ern sf t a An EIP remains associated with your n A instance when you stop it. PIE s im n ar e dt ics ea o s a h t iw r uoy eats i cn n nehw uo y po t s .ti
Elastic IP address
Amazon Elastic Compute Cloud User Guide Determining Your Public and Private IP Addresses
Default VPC
tu lN a f o n d e CP V
You can also determine the public and private IP addresses of your instances using instance metadata. For more information about instance metadata, see Instance Metadata (p. 374).
3.
Multiple IP Addresses
You can specify multiple private IP addresses for your instances. The number of network interfaces and private IP addresses that you can specify for an instance depends on the instance type. For more information, see Instance Families and Types (p. 89). It can be useful to assign multiple private IP addresses to an instance in your VPC to do the following: Host multiple websites on a single server by using multiple SSL certificates on a single server and associating each certificate with a specific IP address. Operate network appliances, such as firewalls or load balancers, that have multiple private IP addresses for each network interface. Redirect internal traffic to a standby instance in case your instance fails, by reassigning the secondary private IP address to the standby instance.
API Version 2013-02-01 460
Topics How Multiple IP Addresses Work (p. 461) Assigning a Secondary Private IP Address (p. 461) Configuring the Operating System on Your Instance to Recognize the Secondary Private IP Address (p. 464) Assigning an Elastic IP Address to the Secondary Private IP Address (p. 465) Viewing Your Secondary Private IP Addresses (p. 465) Unassigning a Secondary Private IP Address (p. 465)
3. 4. 5. 6.
On the Create a New Instance page, click Classic Wizard, and then click Continue. On the CHOOSE AN AMI page, the Quick Start tab displays a list of basic configurations called Amazon Machine Images (AMI). Choose an AMI and click its Select button. On the INSTANCE DETAILS page, set the number and type of instance to launch. You can select a subnet or let us choose one. Confirm your selections, and then click Continue. On the next INSTANCE DETAILS page, under Advanced Instance Options, do the following, and then click Continue: a. b. Select the number of network interfaces to attach to the instance. For each network interface, you can specify a primary private IP address, and one or more secondary private IP addresses. For this example, however, accept the IP address that we automatically assign. Beside Secondary IP Addresses, click Add, and then enter a private IP address in the subnet range, or accept the default, auto-assign, to let us select an address.
c.
Important
After you have added a secondary private IP address to a network interface, you must connect to the instance and configure the secondary private IP address on the instance itself. For more information, see Configuring the Operating System on Your Instance to Recognize the Secondary Private IP Address (p. 464).
7. 8. 9.
On the next INSTANCE DETAILS page, you can specify volumes to attach to the instance besides the volumes specified by the AMI (such as the root device volume), and then click Continue. On the final INSTANCE DETAILS page, specify tags for the instance, such as a user-friendly name, and then click Continue. On the CREATE KEY PAIR page, select an existing key pair or create a new one. If you create a new key pair, you must download it before you can click Continue.
If you're new to Amazon EC2 and haven't created any key pairs, the wizard prompts you to create one. 10. On the CONFIGURE FIREWALL page, select an existing security group for the primary network interface, or create a new one, and then click Continue. The security group for the additional network interface was previously selected when the ENI was created. 11. On the REVIEW page, review the settings, and then click Launch to begin launching your instance.
3. 4.
Select Manage Private IP Addresses. In the Manage Private IP Addresses dialog box, do the following: a. b. c. d. Click Assign a secondary private address. In the Address field, enter a specific IP address that's within the subnet range for the instance, or leave the field blank and we'll select an IP address for you. (Optional) Select Allow reassignment to allow the secondary private IP address to be reassigned if it is already assigned to another network interface. Click Yes, Update, and then click Close.
Configuring the Operating System on Your Instance to Recognize the Secondary Private IP Address
After you assign a secondary private IP address to your instance, you need to configure the operating system on your instance to recognize the secondary private IP address. If you are using Amazon Linux, the ec2-net-utils package takes care of this step for you. It configures additional network interfaces attached while the instance is running, refreshes secondary IP addresses during DHCP lease renewal, and updates the related routing rules. If you require manual control over network configuration, you can remove the ec2-net-utils package. If you are using another Linux distribution, see the documentation for your Linux distribution. Search for information about configuring additional network interfaces and secondary IP addresses. If the instance has two or more interfaces on the same subnet, search for information about using routing rules to work around asymmetric routing. For information about configuring a Windows instance, see Configuring a Secondary Private IP Address for Your Windows Instance in the Amazon Elastic Compute Cloud Microsoft Windows Guide.
5.
Elastic IP Addresses in EC2-Classic (p. 467) Elastic IP Addresses in a VPC (p. 467) Differences Between EC2-Classic and EC2-VPC (p. 468) Allocating an Elastic IP Address (p. 468) Describing Your Elastic IP Addresses (p. 468) Associating an Elastic IP Address with a Running Instance (p. 469) Associating an Elastic IP Address with a Different Running Instance (p. 469) Releasing an Elastic IP Address (p. 469) Using Reverse DNS for Email Applications (p. 469) API and CLI Overview (p. 470) Elastic IP Address Limit (p. 470)
Amazon Elastic Compute Cloud User Guide Differences Between EC2-Classic and EC2-VPC
Reassociation
If you try to associate an EIP that's already associated with another instance, the address is automatically associated with the new instance. If you stop an instance, its EIP is disassociated, and you must re-associate the EIP when you restart the instance. Instances support only a single private IP address and a corresponding EIP.
Instance stop
Multiple IP
Instances support multiple IP addresses, and each one can have a corresponding EIP. For more information, see Multiple IP Addresses (p. 460).
Amazon Elastic Compute Cloud User Guide Associating an Elastic IP Address with a Running Instance
Amazon Elastic Compute Cloud User Guide API and CLI Overview
Associates an Elastic IP address with an instance ec2-associate-address or a network interface. Describes one or more of your Elastic IP addresses. Disassociates an Elastic IP address from the instance or network interface it's associated with. Releases an Elastic IP address allocated to your account.
ec2-describe-addresses DescribeAddresses
ec2-disassociate-address DisassociateAddress
ec2-release-address
ReleaseAddress
You can create a network interface, attach it to an instance, detach it from an instance, and attach it to another instance. The attributes of a network interface follow the network interface as it is attached or detached from an instance and reattached to another instance. When you move a network interface from one instance to another, network traffic is redirected to the new instance. Each instance in a VPC has a default network interface. The default network interface has a primary private IP address in the IP address range of its VPC. You can create and attach additional network interfaces. The maximum number of network interfaces that you can use varies by instance type. For more information, see Private IP Addresses Per ENI Per Instance Type (p. 93). Attaching multiple network interfaces to an instance is useful when you want to: Create a management network. Use network and security appliances in your VPC. Create dual-homed instances with workloads/roles on distinct subnets. Create a low-budget, high-availability solution.
Topics Creating a Management Network (p. 472) Use Network and Security Appliances in Your VPC (p. 472) Creating Dual-homed Instances with Workloads/Roles on Distinct Subnets (p. 472) Create a Low Budget High Availability Solution (p. 473) Best Practices for Configuring Network Interfaces (p. 473) Creating a Network Interface (p. 473) Deleting a Network Interface (p. 474) Viewing Details about a Network Interface (p. 474) Attaching a Network Interface When Launching an Instance (p. 475) Attaching a Network Interface to a Stopped or Running Instance (p. 477) Detaching a Network Interface from an Instance (p. 477) Changing the Security Group of a Network Interface (p. 478) Changing the Source/Destination Checking of a Network Interface (p. 479) Associating an Elastic IP Address with a Network Interface (p. 479) Disassociating an Elastic IP Address from a Network Interface (p. 480) Changing Termination Behavior for a Network Interface (p. 480)
Adding or Editing a Description for a Network Interface (p. 481) Adding or Editing Tags for a Network Interface (p. 481)
Amazon Elastic Compute Cloud User Guide Create a Low Budget High Availability Solution
(subnet) where the database server resides. Instead of routing network packets through the dual-homed instances, each dual-homed instance receives and processes requests on the front end, initiates a connection to the back end, and then sends requests to the servers on the back-end network.
Amazon Elastic Compute Cloud User Guide Attaching a Network Interface When Launching an Instance
Note
If an error occurs when attaching a network interface to your instance, this causes the instance launch to fail.
3. 4.
On the CHOOSE AN AMI page, the Quick Start tab displays a list of basic configurations called Amazon Machine Images (AMI). Choose the AMI that you want to use and click its Select button. On the INSTANCE DETAILS page, set the number and type of instance to launch, and then click Launch Instances. Confirm that your subnet is selected, and then click Continue.
Amazon Elastic Compute Cloud User Guide Attaching a Network Interface When Launching an Instance
5.
Under Advanced Instance Options, select the number of network interfaces to attach to the instance. The number of network interfaces that you can attach varies by instance type. For more information, see Instance Families and Types (p. 89). You can also enter an IP address for the primary network interface (eth0). When you've finished, click Continue.
6.
On the CREATE KEY PAIR page, select an existing key pair or create a new one. If you create a new key pair, you must download it before you can click Continue.
API Version 2013-02-01 476
Amazon Elastic Compute Cloud User Guide Attaching a Network Interface to a Stopped or Running Instance
7.
If you're new to Amazon EC2 and haven't created any key pairs, the wizard prompts you to create one. On the CONFIGURE FIREWALL page, select an existing security group for the primary network interface or create a new one, and then click Continue. The security group for the additional network interface was previously selected when the network interface was created.
8.
On the REVIEW page, details about the primary and additional network interface are displayed. Review the settings, and then click Launch.
Amazon Elastic Compute Cloud User Guide Changing the Security Group of a Network Interface
Note
You can't change security group membership for interfaces owned by other Amazon Web Services, such as Elastic Load Balancing, using the Amazon EC2 console, command line interface, or API actions. To modify a security group owned by one of these services, use the console, command line interface, or API for that service.
Amazon Elastic Compute Cloud User Guide Changing the Source/Destination Checking of a Network Interface
Amazon Elastic Compute Cloud User Guide Disassociating an Elastic IP Address from a Network Interface
Note
By default, network interfaces that are automatically created and attached to instances using the EC2 console are set to terminate when the instance terminates. However, network interfaces created using the ec2-create-network-interface command aren't set to terminate when the instance terminates.
Amazon Elastic Compute Cloud User Guide Adding or Editing a Description for a Network Interface
Storage
Topics Amazon Elastic Block Store (Amazon EBS) (p. 484) Amazon EC2 Instance Store (p. 536) Amazon Simple Storage Service (Amazon S3) (p. 544) Block Device Mapping (p. 545) Amazon EC2 provides you with flexible, cost effective, and easy-to-use data storage options for your instances. Each option has a unique combination of performance and durability. These storage options can be used independently or in combination to suit your requirements. After reading this section, you should have a good understanding about how you can use the data storage options supported by Amazon Elastic Compute Cloud to meet your specific requirements. These storage options include the following: Amazon Elastic Block Store (Amazon EBS) Amazon EC2 instance store Amazon Simple Storage Service (Amazon S3) The following figure shows the relationship between these types of storage.
Amazon EBS Amazon EBS is a durable, block-level storage volume that you can attach to a single, running Amazon EC2 instance. You can use Amazon EBS as a primary storage device for data that requires frequent and granular updates. For example, Amazon EBS is the recommended storage option when you run a database on an instance. Amazon EBS volumes behave like raw, unformatted, external block devices that you can attach to your instances. They persist independently from the running life of an Amazon EC2 instance. After an Amazon EBS volume is attached to an instance, you can use it like any other physical hard drive. For more information, see Amazon Elastic Block Store (Amazon EBS) (p. 484). Amazon EC2 Instance Store Each Amazon EC2 instance, unless it's a micro instance, can access storage from disks that are physically attached to the host computer. This disk storage is referred to as instance store. Instance store provides temporary block-level storage for Amazon EC2 instances. The data on an instance store volume persists only during the life of the associated Amazon EC2 instance. For more information, see Amazon EC2 Instance Store (p. 536). Amazon S3 Amazon S3 is a repository for Internet data. Amazon S3 provides access to reliable and inexpensive data storage infrastructure. It is designed to make web-scale computing easier by enabling you to store and retrieve any amount of data, at any time, from within Amazon EC2 or anywhere on the web. For example, you can use Amazon S3 to store backup copies of your data and applications. For more information, see Amazon Simple Storage Service (Amazon S3) (p. 544). Adding Storage Every time you launch an instance from an AMI, a root storage device is created for that instance. The root storage device contains all the information necessary to boot the instance. For more information, see Root Device Volume (p. 127). You can specify storage volumes in addition to the root device volume when you create an AMI or launch an instance using block device mapping. For more information, see Block Device Mapping (p. 545). You can also attach EBS volumes to a running instance. For more information, see Attaching a Volume to an Instance (p. 500).
Amazon Elastic Block Store (Amazon EBS) provides block level storage volumes for use with Amazon EC2 instances. Amazon EBS volumes are highly available and reliable storage volumes that can be attached to any running instance in the same Availability Zone. The Amazon EBS volumes attached to an Amazon EBS instance are exposed as storage volumes that persist independently from the life of the instance. With Amazon EBS, you only pay for what you use. For more information about Amazon EBS pricing, see the Projecting Costs section of the Amazon Elastic Block Store page. Amazon EBS is recommended when data changes frequently and requires long-term persistence. Amazon EBS is particularly well-suited for use as the primary storage for a file system, database, or for any applications that require fine granular updates and access to raw, unformatted block-level storage. Amazon EBS is particularly helpful for database-style applications that frequently encounter many random reads and writes across the data set. You can attach multiple volumes to the same instance within the limits specified by your AWS account. Your account has a limit on the number of Amazon EBS volumes that you can use, and the total storage available to you. For more information about these limits, and how to request an increase in your limits, see Request to Increase the Amazon EBS Volume Limit.
When you create an Amazon EBS volume in an Availability Zone, it is automatically replicated within that zone to prevent data loss due to failure of any single hardware component. After you create a volume, you can attach it to any Amazon EC2 instance in the same Availability Zone. After you attach a volume, it appears as a native block device similar to a hard drive or other physical device. At that point, the instance can interact with the volume just as it would with a local drive; the instance can format the EBS volume with a file system such as ext3 (Linux) or NTFS (Windows) and install applications. You use the file system to access the stored files. An EBS volume can be attached to only one instance at a time within the same Availability Zone. However, multiple volumes can be attached to a single instance. If you attach multiple volumes to a device that you have named, you can stripe data across the volumes for increased I/O and throughput performance. You can get monitoring data for your Amazon EBS volumes at no additional charge (this includes data for the root device volumes for Amazon EBS-backed instances). For more information, see Monitoring Volumes with CloudWatch (p. 508). Data Persistence An Amazon EBS volume is off-instance storage that can persist independently from the life of an instance. You continue to pay for the volume usage as long as the data persists. By default, EBS volumes that are attached to a running instance automatically detach from the instance with their data intact when that instance is terminated. The volume can then be reattached to a new instance, enabling quick recovery. If you are using an EBS-backed instance, you can stop and restart that instance without affecting the data stored in the attached volume. The volume remains attached throughout the stop-start cycle. This enables you to process and store the data set indefinitely, only using the processing and storage resources when required. The data set persists on the volume until the volume is deleted explicitly. After a volume is deleted, it can't be attached to any instance. By default, EBS volumes that are created and attached to an instance at launch are deleted when that instance is terminated. You can modify this behavior by changing the value of the flag DeleteOnTermination to false when you launch the instance. This modified value causes the volume to persist even after the instance is terminated, and enables you to attach the volume to another instance. Snapshots Amazon EBS provides the ability to create snapshots (backups) of any Amazon EC2 volume. The volume need not be attached to a running instance in order to take a snapshot. Creating a snapshot of an EBS volume writes a copy of the data in the volume to Amazon S3, where it is stored redundantly in multiple Availability Zones. As you continue to write data to a volume, you can periodically create a snapshot of the volume to use as a baseline for new volumes. These snapshots can be used to create multiple new Amazon EBS volumes, expand the size of a volume, or move volumes across Availability Zones. When you create a new volume using a snapshot, it's an exact replica of the original volume. By optionally specifying a different volume size or a different Availability Zone, you can use this functionality to increase the size of an existing volume or to create duplicate volumes in new Availability Zones. The snapshots can be shared with specific AWS accounts or made public. Amazon EBS snapshots are incremental backups, meaning that only the blocks on the device that have changed since your last snapshot will be saved. If you have a device with 100 GiB of data, but only 5 GiB of data have changed since your last snapshot, only the 5 GiB of modified data is written to Amazon S3. Even though snapshots are saved incrementally, the snapshot deletion process is designed so that you need to retain only the most recent snapshot in order to restore the volume. To help categorize and manage your volumes and snapshots, you can tag them with metadata of your choice. For more information, see Tagging Your Amazon EC2 Resources (p. 566).
Standard Provisioned IOPS (input/output operations per second) Standard EBS Volumes Standard volumes offer cost effective storage that is ideal for applications with light or bursty I/O requirements. These volumes deliver approximately 100 IOPS on average, with burst capability of up to hundreds of IOPS. Standard volumes are well suited for use as boot volumes, as their burst capability improves instance start-up times. Provisioned IOPS Volumes To maximize the performance of your I/O-intensive applications, you can use Provisioned IOPS volumes. Provisioned IOPS volumes are designed to meet the needs of I/O-intensive workloads, particularly database workloads, that are sensitive to storage performance and consistency in random access I/O throughput. You specify an IOPS rate when you create the volume, and Amazon EBS provisions that rate for the lifetime of the volume. Amazon EBS currently supports up to 2000 IOPS per volume. You can stripe multiple volumes together to deliver thousands of IOPS per instance to your application. A Provisioned IOPS volume must be at least 10 GB in size. The ratio of IOPS provisioned to the volume size requested can be a maximum of 10. For example, a volume with 1000 IOPS must be at least 100 GB. Provisioned IOPS volumes are designed to offer consistent high performance. They deliver within 10 percent of the provisioned IOPS performance 99.9 percent of the time over a given year, if the following guidelines are met: The volume is attached to an EBS-Optimized instance. For more information, see EBS-Optimized Instances (p. 93). The average queue length is at least 1 per 200 IOPS provisioned. The queue length is the number of pending I/O requests on the volume. If you set the queue length to less than 1 per 200 IOPS provisioned, then your volume will not consistently deliver the IOPS that you've provisioned. Setting the queue length too far above the recommended setting won't affect the IOPS your volume delivers, however per-request latencies will increase. The read and write operations have a block size of 16 KB or less. If the I/O increases above 16 KB, the IOPS delivered drop in proportion to the increase in the size of the I/O. For example, a 1000 IOPS volume can deliver 1000 16 KB writes per second, 500 32 KB writes per second, or 250 64 KB writes per second. As with standard EBS volumes, there is up to a 50 percent reduction in IOPS when you first access the data. Performance is restored after the data is accessed once. For maximum performance consistency with new volumes, we recommend that you read or write to all the blocks on your volume before you use it for a workload. Note that taking a snapshot can reduce the rate of IOPS you get from your volume while the snapshot is pending. To minimize the impact of snapshots on performance of a master node, create snapshots from a read replica of your data. Ideally, create these snapshots during off-peak usage. For more information about volume performance, see Increasing EBS Performance (p. 489).
Common Tasks
This section describes some of the common tasks performed when using Amazon EBS.
Note
The volume data persists in the detached volume. You can attach a detached volume to any running instance. 4 To remove the data from the volume, delete the volume.
Note
The data in this volume is deleted. You can't attach this volume to any instance.
Data Persistence after Instance Termination By default, any volumes that you attach as you launch the instance are automatically deleted when the instance terminates. However, any volumes that you attached to a running instance persist even after the instance terminates. You can change the default behavior using the DeleteOnTermination flag. For an example of how to change this flag when launching an instance, see Using Amazon EC2 Root Device Storage (p. 132). The following diagram and task list describe the different states of a volume from the time it is attached to an instance until the time the instance terminates.
The volume, after instance termination, persists in its modified state. This is a new and different volume; it's no longer in its initial state or associated with its original AMI. When you launch an instance of a particular AMI and then terminate the instance, the detached volume retains its original volume ID. If you launch another instance of the same AMI, the volume associated with the newly launched instance has a different volume ID.
Or
Attach the modified volume to another instance.
Note
The instance launches with the EBS volume (Volume A) in its initial state with a new volume ID.
Data Availability A single Amazon EBS volume is constrained to the single Availability Zone where it is created and becomes unavailable if the Availability Zone itself is unavailable. However, a snapshot of an Amazon EBS volume is available across all of the Availability Zones within a Region. You can use these snapshots to create volumes and make them available in more than one Availability Zone.
Configuration RAID 0
satad etasi gna a vv gdD nA Or/ f rP eo e c I m n a s o f i eht t d irsd u i t b eo c si r ts p a s eh i s t duilio stml e v m e n t o i eh t a tpiro . s tw e s gir frp no e mI f moo ul v e y u ddi n a eh t a .etle ,u o ms v uo y t eg eh t t iats hr g ni t id o a f o . thrt uh p g u o
Data loss isn't operationally tolerable. Your application or databasesebo r lfu e a S D can't tolerate loss of a volume or instance. mh t er f o en o t hm ua t f ioto t ps nd n a O/ I f o artiur d qd ea e myri la ot b . fr d iu eh t eats i cn n o t SBE d ra c em p o o t DI A R , 0 eucb sae er 'uy o gi rrrm no i l la st i w e r o t a r ia p f o ,mo sl v u e gi tml n i wo h hcu m uo y na c .pirts e
Average Queue Length The queue length is the number of pending I/O requests. To benefit from Provisioned IOPS, a Provisioned IOPS volume must maintain an average queue length (rounded up to the nearest whole number) of 1 for every 200 provisioned IOPS in a minute. If you set the queue length to less than 1 per 200 IOPS provisioned, then your volume will not consistently deliver the IOPS that you've provisioned. Setting the queue length too far above the recommended setting won't affect the IOPS your volume delivers, however per-request latencies will increase. For a Provisioned IOPS volume of 500, the queue length average must be 3. If the average queue length is less than 3 for this volume, you aren't consistently sending enough I/O requests. Prepare a New Volume There is a 5 to 50 percent reduction in IOPS when you first access the data on a volume. Performance is restored after the data is accessed once. Therefore, we recommend that you read or write to all the blocks on your volume before you use it. In Linux, the following command reads from all blocks on a volume.
$ dd if=/dev/md0 of=/dev/null
EBS-Optimized instance No
ddee enc mR o e su t oN ,dmr ee m de o n c s a disivr e o n P o S OI P sulo m v e era dgis e e n d o t rvi le e d eh t dtcx e ee p er f rp me co n a y ln o nehw dct ta ea h o t n a dmO eii tp z E B S .ctsi en n a g i la n c S tpr t uoh h g u mr f o a re u bn m f o ml o e v u s i rts e p erew h O/ I er f rp me co n a y tsis c n n o e c t 'n i s .ctic ar li
Yes
Standard EBS
EBS-Optimized instance No
ddee enc mR o e su tscw o-L o t tsis n r e e p e rots g a ro f si t i l na p oc a ta t h era t on er f rp me co n a ,vi t ie e n s hcus s a wo l ni tart oc s n a ssata eb d a r o go l .sl i f e os l A l le w dt iu e s ro f esu s a t oob .mo sl v u e
You must use EBS-Optimized instances to get the full performance benefits of Amazon EBS Provisioned IOPS volumes. For more information, see EBS-Optimized Instances (p. 93). Plan for Snapshots Frequent snapshots provide a higher level of data durability, but they also degrade the performance of your application while the snapshot is in progress. This trade off becomes critical when you have data that's changing rapidly. To minimize the impact of snapshots on performance of a master node, create snapshots from a read replica of your data. Ideally, create these snapshots during off-peak usage.
number) for every 200 provisioned IOPS in a minute. For a Provisioned IOPS volume of 500 IOPS, the volume must maintain an average queue length of 3. The following are possible reasons why a volume isn't meeting the performance threshold: The application isn't sending a sufficient number of I/O requests. The application is sending I/O requests that have a block size larger than 16 KB. [Striped volumes] The application isn't sending I/O requests randomly and consistently across all volumes in the stripe set. Every volume in the stripe set must maintain the recommended average queue length. Snapshots are being created frequently during peak usage.
For this example, the file system we use is XFS. You should use the file system that meets your requirements. On Amazon Linux, use the following command to install the XFS file system.
$ sudo yum install -y xfsprogs
Then, use the following commands to create and mount the XFS file system.
$ sudo mkdir -p /media/p_iops_vol0 && sudo mkfs.xfs /dev/md0 && sudo mount -t xfs /dev/md0 /media/p_iops_vol0 && sudo chown ec2-user:ec2-user /media/p_iops_vol0/
Finally, to get the most accurate results while running these tests, you must pre-warm the volume. For example, on Linux you can read each block on the volume using the following command.
$ dd if=/dev/md0 of=/dev/null
Important
Unless you pre-warm the volume, you might see between a 5 to 50 percent reduction in IOPS when you first access it.
n t ire opc i D s r oF nai a gtb lc ir eh t O/ I er f rp me co n a f o e rots g a mtss s y e o t e b desu h t iw el c O ar .sata ead s b r oF nai a gtb lc ir eh t O/ I er f rp me co n a f o e rots g a mtss s y e o t e b desu h t iw t fsrM oci o L QS . rvr ee S r oF nim i o rf tn o a tu b oa wo h o t eorpi vm eh t er f rp me co n a f o r uoy t fsrM oci o L QS re re vS ,sata ead s b ee s gziO nm i t p sbD et sa a a t a eh t NM D S .et is b w e
SQLIO
Windows
For more information about interpreting the results, go to this Linux tutorial: Inspecting disk IO performance with fio. Oracle ORION Commands Run ORION on the Provisioned IOPS volumes, having it simulate Oracle ASM striping instead of providing it with a stripe set that uses Windows striping. In the directory where you installed ORION, create a file, piops_test.lun, to specify the volumes for your stripe set. The following example file specifies six Provisioned IOPS volumes to be striped.
\\.\D: \\.\E: \\.\F: \\.\G: \\.\H: \\.\I:
The following command performs 16 KB random I/O operations (80 percent reads and 20 percent writes), simulating 64 KB RAID-0 stripes.
orion -run advanced -testname piops_test -size_small 16 -size_large 16 -type rand -simulate raid0 -stripe 64 -write 80 -matrix detailed -num_disks 6
After the command is finished, ORION generates output files with the results in the same directory. For more information about ORION, go to its User Guide. SQLIO Commands Run SQLIO on the stripe set that you created. Create a file, param.txt, to specify your striped set. The contents of this file should look something like this (here, d:\ corresponds to the striped set, and the test uses 6 threads and a 10 GB file).
d:\bigtestfile.dat 6 0x0 10240
The results are displayed in the Command Prompt window. For more information about SQLIO, see the readme.txt file in your SQLIO installation directory.
2. 3. 4. 5. 6. 7. 8. 9.
In the navigation pane, click Volumes. Above the upper pane, click Create Volume. In the Create Volume dialog box, in the Volume Type drop-down list, select Standard or Provisioned IOPS. For more information, see EBS Volume Types (p. 485). In the Size box and GiB drop-down list, select the size of the volume (in GiB or TiB). For Provisioned IOPS volumes, in the IOPS box, enter the maximum number of input/output operations per second (IOPS) that the volume can support. In the Availability Zone drop-down list, select the availability zone in which to launch the instance. For more information, see Regions and Availability Zones (p. 5) In the Snapshot drop-down list, select the ID of the snapshot from which you are launching the volume (optional) Click Yes, Create.
Note
If you specify both a volume size and a snapshot ID, the size must be equal to or greater than the snapshot size. Any AWS Marketplace product codes from the snapshot are propagated to the volume.
Note
Any AWS Marketplace product codes from the snapshot are propagated to the volume.
Amazon EC2 returns information about the volume that is similar to the following example.
VOLUME vol-c7f95aae 80 30T13:54:37+0000 standard us-east-1a creating 2010-03-
Amazon EC2 returns information about the volume that is similar to the following example.
VOLUME vol-c7f95aae 80 30T13:54:37+0000 standard us-east-1a available 2010-03-
Note
Any AWS Marketplace product codes from the snapshot are propagated to the volume.
API
To create an Amazon EBS volume, use the CreateVolume action. Construct the following request.
Windows
/dev/sda1
xvd[a-e]
xvd[f-p]
Important
For Linux/UNIX instance types, we've received reports that some custom kernels might have restrictions that limit use to /dev/sd[f-p] or /dev/sd[f-p][1-6]. If you're having trouble using /dev/sd[q-z] or /dev/sd[q-z][1-6], try switching to /dev/sd[f-p] or /dev/sd[f-p][1-6].
After you have mapped a device using one of these device names, it is mapped to either a scsi drive (sd[a-z]) or an xvd drive (xvd[a-p]), depending on the block device driver of your kernel. If the kernel has an xvd driver, the device is mapped to xvd[a-p]. If the kernel doesn't have an xvd driver, the device is mapped to sd[a-z][1-15]. Base Windows and CentOS HPC (Cluster Compute) images come bundled with an xvd driver, so the devices on Windows and CentOS HPC (Cluster Compute) instances are mapped to xvd[a-p]. The xvd drivers (xvd[a-p]) don't support the use of trailing numbers (xvd[a-p][1-15]). We recommend that you use device names to xvd[a-p] on instances that have xvd drivers. Depending on the size of your instance, Amazon EC2 provides instance store volumes on sd[b-e] (on Linux/UNIX) or xvd[a-e] (on Windows and CentOS HPC). Although you can connect your Amazon EBS volumes using these device names, we highly recommend that you don't because the behavior can be unpredictable. An Amazon EC2 Windows AMI comes with an additional service installed, the Ec2Config Service. The Ec2Config Service runs as a local system and performs various functions to prepare an instance when it first boots up. After the devices have been mapped with the drives, the Ec2Config Service then initializes and mounts the drives. The root drive is initialized and mounted as c:\. The instance stores that comes attached to the instance are initialized and mounted as d:\, e:\, etc. By default, when an EBS volume is attached to a Windows instance, it may show up as any drive letter on the instance. You can change the settings of the Ec2Config Service to set the drive letters of the EBS volumes per your specifications. For more information, go to Using Ec2Config Service in the Microsoft Windows Guide.
Note
The volume and instance must be in the same Availability Zone.
Note
You are limited to total of 16 EBS volume attachments on a Windows instance.
Note
If a volume has an AWS Marketplace product code: The volume can only be attached to the root device of a stopped instance. You must be subscribed to the AWS Marketplace code that is on the volume. The configuration (instance type, operating system) of the instance must support that specific AWS Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance. AWS Marketplace product codes are copied from the volume to the instance.
For an overview of the AWS Marketplace, go to https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.
This example attaches volume vol-4d826724 to instance i-6058a509 in Linux and UNIX and exposes it as device /dev/sdh.
PROMPT> ec2-attach-volume vol-4d826724 -i i-6058a509 -d /dev/sdh
This example attaches volume vol-4d826724 to instance i-6058a509 in Windows and exposes it as device xvdf.
PROMPT> ec2-attach-volume vol-4d826724 -i i-6058a509 -d xvdf
Note
The volume and instance must be in the same Availability Zone.
Note
You are limited to total of 16 EBS volume attachments on a Windows instance.
Note
If a volume has an AWS Marketplace product code: The volume can only be attached to the root device of a stopped instance. You must be subscribed to the AWS Marketplace code that is on the volume. The configuration (instance type, operating system) of the instance must support that specific AWS Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance. AWS Marketplace product codes are copied from the volume to the instance. For an overview of the AWS Marketplace, go to https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.
API
To attach an Amazon EBS volume to an instance, use AttachVolume. Construct the following request.
Note
The volume and instance must be in the same Availability Zone.
Note
You are limited to total of 16 EBS volume attachments on a Windows instance.
Note
If a volume has an AWS Marketplace product code: The volume can only be attached to the root device of a stopped instance. You must be subscribed to the AWS Marketplace code that is on the volume. The configuration (instance type, operating system) of the instance must support that specific AWS Marketplace code. For example, you cannot take a volume from a Windows instance and attach it to a Linux instance. AWS Marketplace product codes are copied from the volume to the instance. For an overview of the AWS Marketplace, go to https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.
Describing Volumes
Topics AWS Management Console (p. 503) Command Line Tools (p. 504) API (p. 505) You can list information about a volume, including the specific instance the volume is attached to.
3.
To view more information about a volume, select it. Information about the volume appears in the lower pane.
This information includes the volume ID, capacity, status (in-use or available), and creation time of each volume. If the volume is attached, an attachment line shows the volume ID, the instance ID to which the volume is attached, the device name exposed to the instance, its status (attaching, attached, detaching, detached), and when it attached.
Tip
You can use ec2-describe-volumes to filter the results to only the volumes that match the criteria you specify. To describe instances and list volumes that are attached to running instances, use the ec2-describe-instances command.
PROMPT> ec2-describe-instances
Tip
You can use ec2-describe-instances to filter the results to only the instances that match the criteria you specify. For more information about block device mapping, see Block Device Mapping (p. 545).
Amazon Elastic Compute Cloud User Guide Making an Amazon EBS Volume Available for Use
API
To describe volumes and list information about all volumes that you own, use the DescribeVolumes action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DescribeVolumes &AUTHPARAMS
Tip
You can use DescribeVolumes to filter the results to only the volumes that match the criteria you specify.
Amazon Elastic Compute Cloud User Guide Making an Amazon EBS Volume Available for Use
to /dev/xvdp. Use the df -h and fdisk -l commands to view your mounted file systems and available disk devices to help you determine the correct device name to use. 3. (Optional) Use the following command to create the ext3 file system.
Caution
This step assumes that you're mounting an empty volume. If you're mounting a volume that already has data on it (for example, a public data set), don't use mkfs before mounting the volume (skip to the next step instead). Otherwise you'll format the volume and delete the existing data.
$ sudo mkfs -t ext3 device_name
4.
5.
6.
(Optional) To enable the instance to reconnect to an Amazon EBS volume on reboot, add the device to the fstab or create a script that automatically mounts the volume on startup.
Caution
If you're mounting a volume that already has data on it (for example, a public data set), make sure you don't reformat the volume and delete the existing data. 4. Select the disk that represents the new Amazon EBS volume.
Amazon Elastic Compute Cloud User Guide Making an Amazon EBS Volume Available for Use
6. A new disk needs to be initialized before it can be used. To initialize the disk: a. In the Disk Management utility, select the new Amazon EBS volume disk. b. On the Disk Management menu, select Action - All Tasks - Initialize Disk. c. In the Initialize Disk dialog, select the disk to initialize, select the desired partition style, and press OK. Your new EBS volume is now available for use. Any data written to this file system is written to the Amazon EBS volume and is transparent to applications using the device.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
Detailed
When you get data from Amazon CloudWatch, you can include a Period request parameter to specify the granularity of the returned data. This is different than the period that we use when we collect the data (5-minute periods). We recommend that you specify a period in your request that is equal to or larger than the collection period to ensure that the returned data is valid. You can get the data using either the Amazon CloudWatch API or the AWS Management Console. The console takes the raw data from the Amazon CloudWatch API and displays a series of graphs based on the data. Depending on your needs, you might prefer to use either the data from the API or the graphs in the console.
Description The total number of bytes transferred in the period. Units: Bytes The total number of operations in the period. Units: Count
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
Metric
Description
VolumeTotalReadTime The total number of seconds spent by all operations that completed in the period. If multiple requests are submitted at the same time, this total could VolumeTotalWriteTime be greater than the length of the period. For example, say the period is 5 minutes (300 seconds); if 700 operations completed during that period, and each operation took 1 second, the value would be 700 seconds.
Units: Seconds
VolumeIdleTime
The total number of seconds in the period when no read or write operations were submitted. Units: Seconds
VolumeQueueLength
The number of read and write operation requests waiting to be completed in the period. Units: Count
VolumeThroughputPercentage Used with Provisioned IOPS volumes only. The percentage of I/O operations per second (IOPS) delivered out of the IOPS provisioned for an EBS volume. Provisioned IOPS volumes deliver within 10 percent of the provisioned IOPS performance 99.9 percent of the time over a given year.
Note
During a write, if there are no other pending I/O requests in a minute, the metric value will be 100 percent. Also, a volume's I/O performance may become degraded temporarily due to an action you have taken (e.g., creating a snapshot of a volume during peak usage, running the volume on a non-EBS-optimized instance, accessing data on the volume for the first time). Units: Percent
VolumeConsumedReadWriteOps Used with Provisioned IOPS volumes only. The total amount of read and write operations consumed in the period.
Units: Count
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
Graph Name Avg Queue Length (ops) % Time Spent Idle Avg Read Size (KiB/op) Avg Write Size (KiB/op) Avg Read Latency (ms/op) Avg Write Latency (ms/op)
Description Using Raw Metrics Avg(VolumeQueueLength) Sum(VolumeIdleTime) / Period * 100 Avg(VolumeReadBytes) / 1024 Avg(VolumeWriteBytes) / 1024 Avg(VolumeTotalReadTime) * 1000 Avg(VolumeTotalWriteTime) * 1000
For the average latency graphs and average size graphs, the average is calculated over the total number of operations (read or write, whichever is applicable to the graph) that completed during the period. The AWS Management Console contains a console for Amazon CloudWatch. In the Amazon CloudWatch console you can search and browse all your AWS resource metrics, view graphs to troubleshoot issues and discover trends, create and edit alarms to be notified of problems, and see at-a-glance overviews of your alarms and AWS resources. For more information, go to AWS Management Console in the Amazon CloudWatch Developer Guide.
Note
Volume status is based on the volume status checks, and does not reflect the volume state. Therefore, volume status does not indicate volumes in the error state (for example, when a volume is incapable of accepting I/O.) If the consistency of a particular volume is not a concern for you, and you'd prefer that the volume be made available immediately if it's impaired, you can override the default behavior by configuring the volume to automatically enable I/O. If you enable the AutoEnableIO volume attribute, the volume status check continues to pass. In addition, you'll see an event that lets you know that the volume was determined to be potentially inconsistent, but that its I/O was automatically enabled. This enables you to check the volume's consistency or replace it at a later time. The following table lists statuses for standard and provisioned IOPS volumes.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
I/O Performance Status (Provisioned IOPS volumes only) Normal (Volume performance is as expected) Degraded (Volume performance is below expectations) Severely Degraded (Volume performance is well below expectations)
ok
Enabled (I/O Enabled or I/O Auto-Enabled) Enabled (I/O Enabled or I/O Auto-Enabled)
warning
impaired
Enabled (I/O Enabled or I/O Auto-Enabled) Disabled (Volume is offline and pending recovery, or is waiting for the user to enable I/O)
Stalled (Volume performance is severely impacted) Not Available (Unable to determine I/O performance because I/O is disabled) Insufficient Data
insufficient-data
To view and work with status checks, you can use the AWS Management Console, the API, or the command line interface.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
5.
If you have a volume with a failed status check (status is impaired), see Working with an Impaired Volume (p. 515).
Alternatively, you can use the Events pane to view all events for your instances and volumes in a single pane. For more information, see Monitoring Volume Events (p. 513).
Get the status of all volumes with a volume status ec2-describe-volume-status --filter of impaired "volume-status.status=impaired"
The following is an example of the output for two volumes, including one that is impaired.
Type VolumeId AvailabilityZone VolumeStatus VOLUME vol-0452396b us-east-1a ok VOLUME vol-2670f74a us-east-1b impaired Type Name Status VOLUMESTATUS io-enabled failed Type EventType NotBefore NotAfter EventId EventDescription EVENT potential-data-inconsistency 2011-12-01T14:00:00.000Z evol61a54008 This is an example Type ActionCode EventId EventType EventDescription ACTION enable-volume-io evol-61a54008 potential-data-inconsistency This is an example
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
If you have a volume with a failed status check (status is impaired), see Working with an Impaired Volume (p. 515). For more information, see ec2-describe-volume-status in the Amazon Elastic Compute Cloud Command Reference Guide.
API
You can use the DescribeVolumeStatus action to retrieve the status of your volumes. For usage information, see DescribeVolumeStatus in the Amazon Elastic Compute Cloud API Reference Guide.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
3. 4.
On the Events page, in Viewing, select Volumes to view only volume status. You can also filter on specific status types. To view the event details of a specific volume, select the volume in the Events page.
If you have a volume where I/O is disabled, see Working with an Impaired Volume (p. 515). If you have a volume where I/O performance is below normal, this might be a temporary condition due to an action you have taken (e.g., creating a snapshot of a volume during peak usage, running the volume on a non-EBS-optimized instance, accessing data on the volume for the first time, etc.).
For more information, see ec2-describe-volume-status in the Amazon Elastic Compute Cloud Command Reference Guide.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
If you have a volume with a failed status check, see Working with an Impaired Volume (p. 515).
API
You can use the DescribeVolumeStatus action to retrieve the status of your volumes and any associated events. For usage information, see DescribeVolumeStatus in the Amazon Elastic Compute Cloud API Reference Guide.
e.
3.
Check the data on the volume. a. b. (Optional) Run the fsck (Linux) or chkdsk (Windows) command. Review the application logs.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
c.
(Optional) If the volume has been impaired for more than 20 minutes you can contact support. Click Troubleshoot Now, and then on the Troubleshoot Status Checks dialog box, click Contact Support to submit a support case.
For information about using the command line interface to enable I/O for a volume, see ec2-enable-volume-io in the Amazon Elastic Compute Cloud Command Line Reference Guide. For information about using the API to enable I/O for a volume, see EnableVolumeIO in the Amazon Elastic Compute Cloud API Reference Guide.
Important
This procedure may cause the loss of write I/Os that were suspended when volume I/O was disabled.
3.
Enable I/O on the volume. a. b. c. In the Navigation pane, under ELASTIC BLOCK STORE, click Volumes. Select the volume that you detached in the previous step. On the Details tab, click Enable Volume IO.
d.
4.
Attach the volume to another instance. For information, see Launching Amazon EC2 Instances (p. 274) and Attaching a Volume to an Instance (p. 500).
API Version 2013-02-01 516
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
5.
Check the data on the volume. a. b. c. (Optional) Run the fsck (Linux) or chkdsk (Windows) command. Review the application logs. (Optional) If the volume has been impaired for more than 20 minutes, you can contact support. Click Troubleshoot Now, and then on the Troubleshoot Status Checks dialog box, click Contact Support to submit a support case.
For information about using the command line interface to enable I/O for a volume, see ec2-enable-volume-io in the Amazon Elastic Compute Cloud Command Line Reference Guide. For information about using the API to enable I/O for a volume, see EnableVolumeIO in the Amazon Elastic Compute Cloud API Reference Guide.
Amazon Elastic Compute Cloud User Guide Monitoring the Status of Your Volumes
6.
In the Modify Auto-Enable Volume IO dialog box, set the Auto-Enable Volume IO option to automatically enable I/O for an impaired volume. To disable the feature, clear the option.
7.
Click Save.
Alternatively, instead of completing steps 4-6 in the previous procedure, go to the Status Checks tab and click Auto-Enable IO Setting.
Amazon Elastic Compute Cloud User Guide Detaching a Volume from an Instance
For more information, see ec2-describe-volume-attribute in the Amazon Elastic Compute Cloud Command Reference Guide. Use the ec2-modify-volume-attribute command as follows to modify the AutoEnableIO attribute of a volume:
ec2-modify-volume-attribute vol-12345678 -auto-enable-io true
For more information, see ec2-modify-volume-attribute in the Amazon Elastic Compute Cloud Command Reference Guide.
API
To view the AutoEnableIO attribute of a volume, use the DescribeVolumeAttribute action. For usage information, see DescribeVolumeAttribute in the Amazon Elastic Compute Cloud API Reference Guide. To modify the AutoEnableIO attribute of a volume, use the ModifyVolumeAttribute action. For usage information, see ModifyVolumeAttribute in the Amazon Elastic Compute Cloud API Reference Guide.
Note
If an Amazon EBS volume is the root device of an instance, it cannot be detached unless the instance is in the stopped state. If the root volume is detached from an instance with an AWS Marketplace product code, then the AWS Marketplace product codes from that volume are no longer associated with the instance. This example unmounts the volume and then explicitly detaches it from the instance. This is useful when you want to terminate an instance or attach a volume to a different instance. To verify that the volume is no longer attached to the instance, see Describing Volumes (p. 503).
Amazon Elastic Compute Cloud User Guide Detaching a Volume from an Instance
2. 3. 4. 5.
For Windows, open Disk Management, right-click the volume to unmount, and select Change Drive Letter and Path. Then, select the mount point to remove and click Remove. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/. Click Volumes in the Navigation pane. The console displays a list of current volumes. Select a volume and click Detach Volume. A confirmation dialog box appears. Click Yes, Detach. The volume is detached from the instance.
Caution
If your volume stays in the detaching state, you can force the detachment using the Force Detach button. Forcing the detachment can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance doesn't get an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures.
2.
For Windows, open Disk Management, right-click the volume to unmount, and select Change Drive Letter and Path. Then, select the mount point to remove and click Remove. To detach the volume, use the ec2-detach-volume command.
PROMPT> ec2-detach-volume vol-4d826724
Caution
If your volume stays in the detaching state, you can force the detachment using the --force option of ec2-detach-volume. Forcing the detachment can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance.
The instance doesn't get an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures.
API
To detach an Amazon EBS volume, use the DetachVolume action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DetachVolume &VolumeId=volume-id &InstanceId=instance-id &AUTHPARAMS
Caution
If your volume stays in the detaching state, you can force the detachment using the Force option of DetachVolume. Forcing the detachment can lead to data loss or a corrupted file system. Use this option only as a last resort to detach a volume from a failed instance. The instance will not have an opportunity to flush file system caches or file system metadata. If you use this option, you must perform file system check and repair procedures.
After you no longer need a volume, you can delete it. After deletion, its data is gone and the volume can't be attached to any instance. However, before deletion, you can store a snapshot of the volume, which you can use to recreate the volume later. This section describes how to delete a volume.
API
To delete a volume, use the DeleteVolume action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DeleteVolume &VolumeId=volume-id &AUTHPARAMS
API (p. 523) After writing data to an Amazon EBS volume, you can periodically create a snapshot of the volume to use as a baseline for new volumes or for data backup. If you make periodic snapshots of a volume, the snapshots are incremental so that only the blocks on the device that have changed since your last snapshot are saved in the new snapshot. Even though snapshots are saved incrementally, the snapshot deletion process is designed so that you need to retain only the most recent snapshot in order to restore the volume. Snapshots occur asynchronously and the status of the snapshot is pending until the snapshot is complete. By default, only you can launch volumes from snapshots that you own. However, you can choose to share your snapshots with specific AWS accounts or make them public. For more information, see Modifying Snapshot Permissions (p. 528). When a snapshot is created, any AWS Marketplace product codes from the volume are propagated to the snapshot.
API
To create a snapshot, use the CreateSnapshot action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=CreateSnapshot &VolumeId=volume-id &AUTHPARAMS
Note
You cannot copy an Amazon Relational Database Service (Amazon RDS) snapshot. When you copy a snapshot, you are only charged for the data transfer and storage used to copy the snapshot data across regions and to store the copied snapshot in the destination region. You are not charged if the snapshot copy fails. However, if you cancel a snapshot copy that is not yet complete, or delete the source snapshot while the copy is in progress, you are charged for the bandwidth of the data transferred. Unlike the create snapshot operation, which is incremental, the copy snapshot operation copies all of the bytes in the snapshot every time. The snapshot is copied across regions using the secure Amazon Simple Storage Service Copy and the snapshot copy receives a snapshot ID thats different from the original snapshots ID. You can use a copy of an Amazon EBS snapshot in the following ways: Geographic Expansion: You can launch your applications in a new region. Migration: You can migrate an application to a new region, to enable better availability and minimizing cost. Disaster Recovery: You can back up your data and logs across different geographical locations at regular intervals. In case of disaster, you can restore your applications using point-in-time backups stored in the secondary region. This minimizes data loss and recovery time.
The Amazon EC2 console, Amazon EC2 CLI, and the API are designed to provide an intuitive customer experience. We use the push model in the console design to minimize user clicks for the Amazon EBS snapshot use cases discussed earlier. You can easily initiate a copy from the console by starting with the source region. We use a pull model in the API and the Amazon EC2 CLI, because these experiences factor in how customers use automation. You only need to know the source snapshot ID and source region to initiate the copy using the Amazon EC2 CLI or API.
5.
6.
In the Copy Snapshot confirmation dialog box, you can click Snapshots to go to the EBS Snapshots pane in the region specified, or click Close.
To view the progress of the copy process later, switch the Amazon EC2 console to the destination region, and then refresh the EBS Snapshots pane. Copies in progress are listed at the top of the EBS Snapshots pane.
2.
To track the progress of the copy, at a command prompt, switch to the destination region, and then type the following:
ec2-describe-snapshots [snapshot_id ...] [-a] [-o owner...] [-r user_id] [[--filter"name=value"] ...]
API
To copy a snapshot using the API
Use the CopySnapshot action to construct the following request:
https://ec2.amazonaws.com/?Action=CopySnapshot &AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE &Description=My%20snapshot &Signature=VjpSFePIKxDc1IUy92W3SBApdLiap7nno4pEc9iEXAMPLE &SignatureMethod=HmacSHA256 &SignatureVersion=2 &SourceRegion=us-west-1 &SourceSnapshotId=snap-2EXAMPLE &Timestamp=2012-12-11T02%3A03%3A35.713Z &Version=2012-12-01
Describing Snapshots
Topics
API Version 2013-02-01 526
AWS Management Console (p. 527) Command Line Tools (p. 527) API (p. 527) This section describes how to view snapshots that you created.
4.
If the snapshot is in the process of being created, the status is pending and a percentage complete is displayed (e.g., 60%). After the snapshot is complete, its status changes to completed.
Tip
If you have a large number of snapshots, you can use ec2-describe-snapshots to filter the results to only the snapshots that match the criteria you specify.
API
To describe snapshots, use the DescribeSnapshots action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DescribeSnapshots &SnapshotId=snapshot-id &AUTHPARAMS
<item> <snapshotId>snap-05b4aa6c</snapshotId> <volumeId>vol-d11fbbb8</volumeId> <status>completed</status> <startTime>2010-03-23T09:43:52.000Z</startTime> <progress>100%</progress> <ownerId>999988887777</ownerId> <volumeSize>20</volumeSize> <description/> </item> </snapshotSet> </DescribeSnapshotsResponse>
Tip
If you have a large number of snapshots, you can use DescribeSnapshots to filter the list to only the snapshots that match criteria you specify.
Important
When you share a snapshot (whether by sharing it with another AWS account or making it public to all), you are giving others access to all the data on your snapshot. Share snapshots only with people with whom you want to share all your snapshot data.
Important
Making your snapshot public shares all snapshot data with everyone. Snapshots with AWS Marketplace product codes cannot be made public. To make the snapshot public, select Public and click Save. To expose the snapshot only to specific AWS accounts, select Private, enter the IDs of those AWS accounts, and click Save. The console modifies permissions for the snapshot.
If there are no permissions set on the snapshot, the output is empty. 2. Choose whether to make the snapshot public, or to share it with a specific AWS account.
Important
Making your snapshot public shares all snapshot data with everyone. Snapshots with AWS Marketplace product codes cannot be made public. To make the snapshot public, use the ec2-modify-snapshot-attribute command as follows.
PROMPT> ec2-modify-snapshot-attribute snap_id -c --add all
To share the snapshot with a particular AWS account, use the ec2-modify-snapshot-attribute command as follows
PROMPT> ec2-modify-snapshot-attribute snap_id -c --add account_id
API
To modify snapshot permissions
1. Use the DescribeSnapshotAttribute action to describe the snapshot's permissions. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DescribeSnapshotAttribute &SnapshotId=snapshot-id &AUTHPARAMS
2.
Choose whether to make the snapshot public, or to share it with a specific AWS account.
Important
Making your snapshot public shares all snapshot data with everyone. Snapshots with AWS Marketplace product codes cannot be made public. To make the snapshot public, use the ModifySnapshotAttribute action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=ModifySnapshotAttribute &SnapshotId=snapshot-id &CreateVolumePermission.Add.1.Group=all &AUTHPARAMS
To share the snapshot with a particular AWS account, use the ModifySnapshotAttribute action as follows.
https://ec2.amazonaws.com/ ?Action=ModifySnapshotAttribute &SnapshotId=snapshot-id &CreateVolumePermission.Add.1.UserId=111122223333 &AUTHPARAMS
Note
If you make periodic snapshots of a volume, the snapshots are incremental so that only the blocks on the device that have changed since your last snapshot are saved in the new snapshot. Even though snapshots are saved incrementally, the snapshot deletion process is designed so that you need to retain only the most recent snapshot in order to restore the volume. You cannot delete a snapshot of the root device of an EBS volume used by a registered AMI. You must first de-register the AMI before you can delete the snapshot.
API
To delete a snapshot, use the DeleteSnapshot action. Construct the following request.
https://ec2.amazonaws.com/ ?Action=DeleteSnapshot &SnapshotId=snapshot-id &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Using Public Data Sets
Launching an Instance
You'll attach a volume based on the public data set to an instance. Launch the instance as you typically launch an instance. For more information, see Launching Amazon EC2 Instances (p. 274).
Amazon Elastic Compute Cloud User Guide Using Public Data Sets
Amazon EBS returns information about the volume similar to the following example.
VOLUME vol-4d826724 85 us-east-1a creating 2008-02-14T00:00:00+0000
Amazon EBS returns information about the volume similar to the following example.
VOLUME vol-4d826724 85 us-east-1a available 2008-07-29T08:49:25+0000
API
To create an Amazon EBS volume
Construct the following Query request.
Amazon Elastic Compute Cloud User Guide API and Command Overview
Description Attaches the specified volume to a specified instance, exposing the volume using the specified device name. A volume can be attached to only a single instance at any time. The volume and instance must be in the same Availability Zone. The instance must be in the running or stopped state. Copies a point-in-time snapshot of an Amazon Elastic Block Store (Amazon EBS) volume and stores it in Amazon Simple Storage Service (Amazon S3). You can copy the snapshot within the same region or from one region to another. You can use the snapshot to create new Amazon EBS volumes or Amazon Machine Images (AMIs). Creates a snapshot of the volume you specify. After the snapshot is created, you can use it to create volumes that contain exactly the same data as the original volume. Creates a new Amazon EBS volume using the specified size and type, or based on a previously created snapshot. Deletes a partially or fully uploaded disk image for conversion from Amazon S3.
ec2-copy-snapshot CopySnapshot
ec2-create-snapshot CreateSnapshot
Amazon Elastic Compute Cloud User Guide API and Command Overview
Description Deletes the specified snapshot. This command does not affect currently running Amazon EBS volumes, regardless of whether they were used to create the snapshot or were derived from the snapshot. Deletes the specified volume. The command does not delete any snapshots that were created from the volume. Describes attributes for a snapshot.
ec2-describe-snapshots Describes the specified snapshot. DescribeSnapshots Describes all snapshots, including their source volume, snapshot initiation time, progress (percentage complete), and status (pending, completed, etc.). ec2-describe-volumes DescribeVolumes
Describes your volumes, including size, volume type, source snapshot, Availability Zone, creation time, status (available or in-use). If the volume is in-use, an attachment line shows the volume ID, the instance ID to which the volume is attached, the device name exposed to the instance, its status (attaching, attached, detaching, detached), and when it attached.
ec2-describe-volume-attribute Describes an attribute of a volume. DescribeVolumeAttribute ec2-describe-volume-status Describes the status of one or more volumes. Volume status provides the result of the checks performed on your volumes to determine events DescribeVolumeStatus that can impair the performance of your volumes. ec2-detach-volume DetachVolume
Detaches the specified volume from the instance it's attached to. This command does not delete the volume.The volume can be attached to another instance and will have the same data as when it was detached. Enables I/O operations for a volume that had I/O operations disabled because the data on the volume was potentially inconsistent. Creates a new import volume task using metadata from the specified disk image, and imports the image to Amazon EC2. Modifies permissions for a snapshot (i.e., who can create volumes from the snapshot). You can specify one or more AWS accounts, or specify all to make the snapshot public.
ec2-enable-volume-io EnableVolumeIO ec2-import-volume ImportVolume ec2-modify-snapshotattribute ModifySnapshotAttrib ute ec2-modify-volume-at tribute ModifyVolumeAttribute
Modifies a volume's attributes to determine whether a volume should be automatically enabled for I/O operations.
Description
ec2-reset-snapshot-a Resets permission settings for the specified snapshot. ttribute ResetSnapshotAttribute
The data in an instance store persists only during the lifetime of its associated Amazon EC2 instance.
Important
If an instance reboots (intentionally or unintentionally), data in the instance store persists. However, data on instance store volumes is lost under the following circumstances: Failure of an underlying drive Stopping an Amazon EBS-backed instance Terminating an instance The size of an instance store ranges from 150 GiB to up to 3.3 TiB and varies by Amazon EC2 instance type. Larger Amazon EC2 instances have larger instance stores. For more information, see Instance Stores Available On Instance Types (p. 537).
Amazon Elastic Compute Cloud User Guide Instance Stores Available On Instance Types
An Amazon EC2 instance store consists of one or more instance store volumes. These volumes are usable only from a single Amazon EC2 instance during its lifetime; they can't be detached and then attached to another instance. Instance store volumes must be mounted before they can be used. By default, instances launched from an Amazon EBS-backed instance have no mounted instance store volumes. Instances launched from an instance store-backed AMI have a mounted instance store volume for the virtual machine's root device volume, and can have other mounted instances store volumes, depending on the instance type. For more information on instance store-backed AMIs and Amazon EBS-backed AMIs, see AMI Basics (p. 22). When you launch an instance, whether it's launched from an Amazon EBS-backed AMI or an instance store-backed AMI, you can attach instance store volumes to the instance using block device mapping. For more information, see Block Device Mapping (p. 545). If you need a permanent storage solution, or if you need to improve storage latency or throughput, we recommend using Amazon EBS volumes instead of instance store volumes. For more information, see Amazon Elastic Block Store (Amazon EBS) (p. 484).
Instance Store Volumes None (use Amazon EBS volumes) 1 x 150 GiB 1 x 400 GiB 2 x 420 GiB (840 GiB) 4 x 420 GiB (1680 GiB) None (use Amazon EBS volumes) None (use Amazon EBS volumes) 1 x 340 GiB 4 x 420 GiB (1680 GiB) 1 x 410 GiB 1 x 840 GiB 2 x 840 GiB (1680 GiB) 2 x 1 TiB SSD (2 TiB)
hi1.4xlarge
Amazon Elastic Compute Cloud User Guide Instance Store Device Names
Type High Storage High-Memory Cluster Cluster Compute Quadruple Extra Large
Name
hs1.8xlarge cr1.8xlarge cc1.4xlarge
Instance Store Volumes 24 x 2 TiB hard disk drives (48 TiB) 2 x 120 GiB SSD (240 GiB) 2 x 840 GiB (1680 GiB) 4 x 840 GiB (3360 GiB) 2 x 840 GiB (1680 GiB)
Cluster Compute Eight Extra Large cc2.8xlarge Cluster GPU Quadruple Extra Large cg1.4xlarge
Formatted and mounted as /mnt or Formatted and mounted on m1.medium, /media/ephemeral0 on m1.medium, m1.large, m1.xlarge, c1.xlarge, m1.large, m1.xlarge, c1.xlarge, m2.xlarge, and m2.2xlarge. cc1.4xlarge, cc2.8xlarge, cr1.8xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, and hi1.4xlarge.
Amazon Elastic Compute Cloud User Guide Amazon EC2 Instance Storage Usage Scenarios
Device Name Linux/UNIX instance store-backed instance /dev/sdc, xvdc Available on m1.large, m1.xlarge, cc2.8xlarge, cc1.4xlarge, c1.xlarge, cr1.8xlarge, and hi1.4xlarge.
Windows instance store-backed instance Formatted and mounted on m1.large, m1.xlarge, c1.xlarge, and m2.4xlarge.
Available on m1.xlarge, c1.xlarge, and Formatted and mounted on m1.xlarge and cc2.8xlarge. c1.xlarge. Available on m1.xlarge and c1.xlarge. Formatted and mounted on m1.xlarge and c1.xlarge.
An instance can have multiple instance store volumes mapped to a device. However, the number and size of these volumes must not exceed the instance store available for the instance type. For more information, see Instance Stores Available On Instance Types (p. 537).
Tip
Any data on an instance store volume is deleted if the instance stops, fails, or terminates. Therefore, do not rely on instance store volumes for valuable, long-term data. Instead, use a replication strategy across multiple instances to keep your data safe, store your persistent data in Amazon S3, or use Amazon EBS volumes for persistent data.
Tip
Data on instance store volumes is not included when you bundle an AMI. For example, if you have an instance store-backed Windows instance, the D: drive on that instance is typically an instance store volume, and it's not included in an AMI that you bundle from that instance.
Amazon Elastic Compute Cloud User Guide Amazon EC2 Instance Storage Usage Scenarios
4 5
On the Start menu, choose Computer. Devices listed: Local Disk C:/ 9.98GiB Local Disk D:/ 419GiB Local Disk E:/ 419GiB
6 7
Double-click Local Disk C:/. You can see the list of installed applications. This is your root drive. Double-click Local Disk D:/ and then double-click Local Disk E:/. These drives are empty. They are the instance stores that come with your m1.large instance, and they are available for you to use with your applications.
The following procedure describes how to launch an Amazon EBS-backed m1.large Linux instance with instance store volumes.
You can also map instance store volumes to block devices when you create an AMI. The instances launched from such an AMI have instance store volumes at boot time. For information on adding a block device mapping while creating an AMI, see the section called Creating Your Own AMIs (p. 34). The following procedure describes how to access the instance store volumes from within an Amazon EC2 instance store-backed m1.large Windows instance.
Tasks for Accessing Instance Stores on Amazon EC2 instance store-backed Windows Instances
1 Locate an Amazon EC2 instance store-backed Windows AMI.
Amazon Elastic Compute Cloud User Guide Amazon EC2 Instance Storage Usage Scenarios
2 Launch an m1.large instance. 3 Connect to the instance. 4 On the Start menu, choose Computer. 5 Devices listed: Local Disk C:/ 9.98GiB Local Disk D:/ 419GiB Local Disk E:/ 419GiB
6 Double-click Local Disk C:/. You see the list of all installed applications. This is your root drive. 7 Double-click Local Disk D:/ and then double-click Local Disk E:/. These are empty. They are the instance store volumes that come with your m1.large instance, and they are available to use with your applications just like any physical drive.
Depending on the instance type, some instance store volumes on Amazon EC2 instance store-backed Linux and UNIX instances are not mounted when the instance is launched. For example, on an m1.large Linux and UNIX instance, the device /dev/sdc, although formatted and available, must be mounted before it can be used. The following procedure describes how to access the instance store from within Amazon EC2 instance store-backed m1.large Linux instance.
Amazon Elastic Compute Cloud User Guide Using Amazon EC2 Instance Storage
specifying the mapping /dev/sdc=none when launching an instance prevents /dev/sdc from attaching to the instance. For more information on block device mapping, see Block Device Mapping (p. 545).
Note
You cannot register an image where a secondary (non-root) snapshot has AWS Marketplace product codes.
Tip
If you're using the command line tools on a Windows computer, you must put quotation marks around any part of the command that includes an equal sign. For example: ... -b "/dev/sdc=ephemeral0" ....
PROMPT> ec2-register -n My_Image_Name -d My_image_description --root-devicename /dev/sda1 -b /dev/sda1=snap-12345678:80:false -b /dev/sdc=ephemeral0
Any instance you launch from this AMI includes the instance store volumes that you specified when you created the AMI. You can confirm that the instance store devices are available from within the instance itself using instance metadata. For more information, see Viewing Block Device Mappings (p. 548).
API
Use the RegisterImage action, specifying a block device mapping that includes the instance store volumes for the image.
API Version 2013-02-01 542
Amazon Elastic Compute Cloud User Guide Using Amazon EC2 Instance Storage
Note
You cannot register an image where a secondary (non-root) snapshot has AWS Marketplace product codes.
For information about the auth parameters, go to Common Query Parameters in the Amazon Elastic Compute Cloud API Reference. The following is an example response.
<RegisterImageResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <imageId>ami-61a54008</imageId> </RegisterImageResponse>
Any instance you launch from this AMI includes the instance store volumes that you specified when you created the AMI. You can confirm the instance storage volumes are available from within the instance itself using instance metadata. For more information, see Viewing Block Device Mappings (p. 548)).
Note
Make sure to unmount the drive before performing this command.
Initialization can take a long time (about 8 hours for an extra large instance). To initialize the instance store volumes, use the following commands on the m1.large, m1.xlarge, c1.xlarge, m2.xlarge, m2.2xlarge, and m2.4xlarge instance types:
dd dd dd dd if=/dev/zero if=/dev/zero if=/dev/zero if=/dev/zero of=/dev/sdb of=/dev/sdc of=/dev/sdd of=/dev/sde bs=1M bs=1M bs=1M bs=1M
For information about the instance storage that is available for each instance type, see Instance Stores Available On Instance Types (p. 537). To perform initialization on all instance store volumes at the same time, use the following command:
dd if=/dev/zero bs=1M|tee /dev/sdb|tee /dev/sdc|tee /dev/sde > /dev/sdd
RAID Configuration
Configuring drives for RAID initializes them by writing to every drive location. When configuring software-based RAID, make sure to change the minimum reconstruction speed:
echo $((30*1024)) > /proc/sys/dev/raid/speed_limit_min
Amazon Elastic Compute Cloud User Guide Block Device Mapping Concepts
launched from the AMI. Alternatively, you can specify a block device mapping when you launch an instance, so this mapping overrides the one specified in the AMI from which you launched the instance.
Tip
On some devices, the names that you specify in your block device mapping can conflict with the default block device names. To avoid this issue, do not use names of the form /dev/sda[1-15]. [Windows] The device name within Amazon EC2, as shown in this table. The block device driver for the instance assigns the actual volume name when mounting the volume, and the name assigned can be different than the name that Amazon EC2 recommends. Reserved for the root device Recommended for instance store volumes Recommended for EBS volumes Possible for EBS volumes /dev/sda1 xvd[a-e] xvd[f-p] xvd[a-p] /dev/sda[1-2] /dev/sd[b-e]
[Instance store volumes only] The virtual device: ephemeral[0-3]. [EBS volumes only] The ID of the snapshot to use to create the block device (snap-xxxxxxxx). This value is optional as long as you specify a volume size. [EBS volumes only] The size of the volume, in GiB. The specified size must be greater than or equal to the size of the specified snapshot. [EBS volumes only] Whether to delete the volume on instance termination (true or false). The default value is true.
API Version 2013-02-01 546
Amazon Elastic Compute Cloud User Guide Block Device Mapping Concepts
[EBS volumes only] The volume type (standard or io1). The default value is standard. [EBS volumes only] The number of input/output operations per second (IOPS) that the volume supports. (Not used with standard volumes.)
Note that this example block device mapping is used in the example commands and APIs in this topic. You can find example commands and APIs that create block device mappings here: Specifying a Block Device Mapping for an AMI (p. 548) Updating the Block Device Mapping when Launching an Instance (p. 553)
Amazon Elastic Compute Cloud User Guide AMI Block Device Mapping
instance determines which devices are used when the volumes are formatted and mounted. For more information, see Attaching a Volume to an Instance (p. 500). With a Windows instance, the device names specified in the block device mapping are mapped to their corresponding block devices when the instance first boots, and then the Ec2Config service initializes and mounts the drives. The root device volume is mounted as C:\. The instance store volumes are mounted as D:\, E:\, and so on. When an EBS volume is mounted, it can be mounted using any available drive letter. However, you can configure how the Ec2Config Service assigns drive letters to EBS volumes; for more information, see Using EC2Config Service.
Amazon Elastic Compute Cloud User Guide AMI Block Device Mapping
This command maps /dev/sdc to ephemeral0, /dev/sdh to an EBS volume based on a snapshot, and /dev/sdj to an empty EBS volume that is 100 GiB in size. The output is the ID for your new AMI.
IMAGE ami-72aa081b
For more information, see ec2-register. To verify that the AMI was created successfully, look for it in the Amazon EC2 Console (click AMIs in the Navigation pane, then click Owned By Me in the Viewing menu) or the output of the following command:
ec2-describe-images -o self
Alternatively, if youve already attached volumes to an instance, you can use one of these methods as appropriate. Amazon EBS-backed AMI ec2-create-image Instance store-backed AMI Creating an Instance Store-Backed AMI From an Existing AMI (p. 40) Creating an Instance Store-Backed Windows AMI
API
Use RegisterImage to create an AMI with a block device mapping. For example, use this request to register a Linux AMI with its root device, an instance store volume, an EBS volume based on a snapshot, and an empty 100 GiB EBS volume.
https://ec2.amazonaws.com/?Action=RegisterImage &Name=ImageName &RootDeviceName=/dev/sda1 &BlockDeviceMapping.1.DeviceName=/dev/sdb &BlockDeviceMapping.1.VirtualName=ephemeral0 &BlockDeviceMapping.2.DeviceName=/dev/sdh &BlockDeviceMapping.2.Ebs.SnapshotId=snap-d5eb27ab &BlockDeviceMapping.3.DeviceName=/dev/sdj &BlockDeviceMapping.3.Ebs.VolumeSize=100 &AUTHPARAMS
Note that AUTHPARAMS represents common required parameters. For more information, see Common Query Parameters or Query Requests (p. 590). This request maps /dev/sdc to ephemeral0, /dev/sdh to an EBS volume based on a snapshot, and /dev/sdj to an empty EBS volume that is 100 GiB in size. The response includes the ID for your new AMI.
... <imageId>ami-72aa081b</imageId> ...
Amazon Elastic Compute Cloud User Guide AMI Block Device Mapping
For more information, see RegisterImage. To verify that the AMI was created successfully, look for it in the Amazon EC2 Console (click AMIs in the Navigation pane, then click Owned By Me in the Viewing menu) or the output of the following command:
ec2-describe-images o self
Alternatively, if youve already attached volumes to an Amazon EBS-backed instance, you can use CreateImage to create an AMI from this instance with a block device mapping that attaches those same volumes.
Amazon Elastic Compute Cloud User Guide AMI Block Device Mapping
The output includes the block device mapping for your AMI. The following information is available for EBS volumes: The device name within Amazon EC2 The ID of the snapshot used when creating the block device (optional) The size of the volume, in GiB The volume type.
API
Use DescribeImages to enumerate the EBS volumes in the block device mapping for an AMI. For example, use this request to get information about an AMI, including its block device mapping.
Amazon Elastic Compute Cloud User Guide AMI Block Device Mapping
Note that AUTHPARAMS represents common required parameters. For more information, see Common Query Parameters or Query Requests (p. 590). The response includes the block device mapping for your AMI. The following information is available for EBS volumes: The device name within Amazon EC2 The ID of the snapshot used when creating the block device (optional) The size of the volume, in GiB Whether to delete the volume on instance termination (default is true) The volume type. Heres an example response for a Linux AMI.
... <blockDeviceMapping> <item> <deviceName>/dev/sda1</deviceName> <ebs> <snapshotId>snap-e1eb279f</snapshotId> <volumeSize>8</volumeSize> <deleteOnTermination>true</deleteOnTermination> <volumeType>standard</volumeType> </ebs> </item> <item> <deviceName>/dev/sdh</deviceName> <ebs> <snapshotId>snap-d5eb27ab</snapshotId> <volumeSize>200</volumeSize> <deleteOnTermination>true</deleteOnTermination> <volumeType>standard</volumeType> </ebs> </item> <item> <deviceName>/dev/sdj</deviceName> <ebs> <volumeSize>100</volumeSize> <deleteOnTermination>true</deleteOnTermination> <volumeType>standard</volumeType> </ebs> </item> </blockDeviceMapping> ...
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
6.
When you've finished modifying the block device mapping, click Save details.
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
For example, suppose that an EBS-backed Linux AMI specifies the following block device mapping: /dev/sdb=ephemeral0 /dev/sdh=snap-92d333fb /dev/sdj=:100 To prevent /dev/sdj from attaching to an instance launched from this AMI, use this option.
b "/dev/sdj=none"
Notice that we didnt need to specify the snapshot ID for /dev/sdh, because specifying the device name is enough to identify the volume. To attach an additional instance store volume, /dev/sdc, use this option. If the instance type doesnt support more than one instance store volume, this option has no effect.
b "/dev/sdc=ephemeral1"
API
Use RunInstances to define an entry for the block mapping for an instance. For example, suppose that an EBS-backed Linux AMI specifies the following block device mapping: /dev/sdb=ephemeral0 /dev/sdh=snap-92d333fb /dev/sdj=:100 Use this request to do the following: prevent /dev/sdj from attaching to an instance launched from this AMI increase the size of /dev/sdh to 300 GiB attach an additional instance store volume, /dev/sdc (if the instance type supports it)
http://ec2.amazonaws.com/?Action=RunInstances &ImageId.1=ami-72aa081b ... &BlockDeviceMapping.1.DeviceName=/dev/sdj &BlockDeviceMapping.1.Ebs.NoDevice=true &BlockDeviceMapping.2.DeviceName=/dev/sdh &BlockDeviceMapping.2.Ebs.VolumeSize=300 &BlockDeviceMapping.3.DeviceName=/dev/sdc &BlockDeviceMapping.3.VirtualName=ephemeral1 &AUTHPARAMS
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
Note that AUTHPARAMS represents common required parameters. For more information, see Common Query Parameters or Query Requests (p. 590). Notice that we didnt need to specify the snapshot ID for /dev/sdh, because specifying the device name is enough to identify the volume. For more information, see RunInstances.
Note
For instances launched before the release of the 2009-10-31 API, AWS cant display the block device mapping. You must detach and reattach the volumes so that AWS can display the block device mapping.
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
5.
To display additional information about a block device, click its entry under Block Devices. This displays the following information for the block device: EBS ID (vol-xxxxxxxx) Root Device Type (ebs) Attachment time (yyyy-mmThh:mm:ss.ssTZD) Block device status (attaching, attached, detaching, detached) Delete on termination (Yes, No) Snapshot ID (snap-xxxxxxxx)
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
ec2-describe-instances i-xxxxxxxx
The output includes the block devices for your instance. The following information is available for EBS volumes: The device name within Amazon EC2 The volume ID The time when the attachment was initiated Whether to delete the volume on instance termination The volume type (standard or io1) The number of input/output operations per second (IOPS) that the volume supports. (Not used with standard volumes.) The output for a Linux instance looks something like this.
BLOCKDEVICE BLOCKDEVICE BLOCKDEVICE /dev/sda1 /dev/sdh /dev/sdj vol-xxxxxxxx vol-xxxxxxxx vol-xxxxxxxx yyyy-mmThh:mm:ss.sTZD yyyy-mmThh:mm:ss.sTZD yyyy-mmThh:mm:ss.sTZD true true true
To view this information plus the status (attaching, attached, detaching, detached), run the ec2-describe-instances command with the v option to see the full SOAP response. For more info, see ec2-describe-instances.
API
Use DescribeInstances to enumerate the EBS volumes in the block device mapping for an instance. For example, use this request to get information about an instance, including its block devices.
https://ec2.amazonaws.com/?Action=DescribeInstances &InstanceId.1=i-xxxxxxxx &AUTHPARAMS
Note that AUTHPARAMS represents common required parameters. For more information, see Common Query Parameters or Query Requests (p. 590). The response includes the block devices for your instance. The following information is available for EBS volumes: The device name within Amazon EC2 The volume ID The status (attaching, attached, detaching, detached) The time when the attachment was initiated Whether to delete the volume on instance termination The volume type (standard or io1) The number of input/output operations per second (IOPS) that the volume supports. (Not used with standard volumes.) Heres example output for a Linux instance.
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
... <blockDeviceMapping> <item> <deviceName>/dev/sda1</deviceName> <ebs> <volumeId>vol-xxxxxxxx</volumeId> <status>attached</status> <attachTime>yyyy-mm-ddThh:mm:ss.sTZD</attachTime> <deleteOnTermination>true</deleteOnTermination> <volumeType>standard</volumeType> </ebs> </item> <item> <deviceName>/dev/sdh</deviceName> <ebs> <volumeId>vol-xxxxxxxx</volumeId> <status>attached</status> <attachTime>yyyy-mm-ddThh:mm:ss.sTZD</attachTime> <deleteOnTermination>true</deleteOnTermination> <volumeType>standard</volumeType> </ebs> </item> <item> <deviceName>/dev/sdj</deviceName> <ebs> <volumeId>vol-xxxxxxxx</volumeId> <status>attached</status> <attachTime>yyyy-mm-ddThh:mm:ss.sTZD</attachTime> <deleteOnTermination>true</deleteOnTermination> <volumeType>standard</volumeType> </ebs> </item> </blockDeviceMapping> ...
Viewing the Instance Block Device Mapping for Instance Store Volumes
When you view the block device mapping for your instance, you can see only the EBS volumes, not the instance store volumes. You can use instance metadata to query the complete block device mapping. The base URI for all requests for instance metadata is http://169.254.169.254/latest/. First, connect to your running instance. If the instance is running Linux, the GET command is already available. If the instance is running Windows, install wget on the instance, and replace GET with wget in the examples below. Use this query on a running instance to get its block device mapping.
GET http://169.254.169.254/latest/meta-data/block-device-mapping/
The response includes the names of the block devices for the instance. For example, the output for an instance store-backed m1.small instance looks like this.
Amazon Elastic Compute Cloud User Guide Instance Block Device Mapping
The ami device is the root device as seen by the instance. The instance store volumes are named ephemeral[0-3]. The swap device is for the page file. If youve also mapped EBS volumes, they appear as ebs1, ebs2, and so on. To get details about an individual block device in the block device mapping, append its name to the previous query, as shown here.
GET http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0
Resource Locations
The following table describes which Amazon EC2 resources are global, regional, or based on Availability Zone. Resource AWS Account DevPay Product Codes Type Global Global Description You use the same AWS account in all Regions. You use the same DevPay product codes throughout all Regions. Includes the AMI ID, Instance ID, EBS Volume ID, EBS Snapshot ID, and so on. Instances are tied to Availability Zones. However, the instance ID is tied to the Region. AMIs are tied to the Region where its files are located within Amazon S3. Security groups are not copied across Regions. Instances within the Region cannot communicate with instances outside the Region using group-based firewall rules. Traffic from instances in another Region is seen as WAN bandwidth.
Regional
Availability Zone
AMIs
Regional
Security Groups
Regional
Description The SSH key pairs that you create with ec2-add-keypair, CreateKeyPair, or in the AWS Management Console work only in the Region where you create them. However, you can optionally create an RSA key pair with a third-party tool and upload the public key to AWS. That key pair works in all Regions. For more information, go to ec2-import-keypair in the Amazon Elastic Compute Cloud Command Line Reference or ImportKeyPair in the Amazon Elastic Compute Cloud API Reference. Includes security group names, SSH key pair names, and so on. Although you can create the same names in multiple Regions, they have no relationship to each other. Elastic IP addresses are tied to a Region and cannot be mapped across Regions. An Amazon EBS volume must be located within the same Availability Zone as the instance to which it attaches. Snapshots are tied to Regions and can only be used for volumes within the same Region.
User-Supplied Identifiers
Regional
Elastic IP Addresses
Regional
EBS Volumes
Availability Zone
EBS Snapshots
Regional
Related Topic
Regions and Availability Zones (p. 119)
Amazon Elastic Compute Cloud User Guide Listing and Filtering Your Resources
Filters
The resulting lists of resources can be long, so you might want to filter the results to include only the resources that match certain criteria. For example, you can list only the public 64-bit Windows AMIs that use an Amazon EBS volume as the root device volumes. As another example, you can list only the Amazon EBS snapshots that have been tagged with a certain value. You can specify multiple filter values. For example, you can list all the instances whose type is either m1.small or m1.large. The resource must match at least one of the values to be included in the resulting resource list. You can also specify multiple filters. For example, you can list all the instances whose type is either m1.small or m1.large, and that have an attached EBS volume that is set to delete when the instance terminates. The instance must match all your filters to be included in the results. You can also use wildcards with the filter values. An asterisk (*) matches zero or more characters, and a question mark (?) matches exactly one character. For example, you can use *database* as a filter value to get all EBS snapshots that include database in the description. If you were to specify database as the filter value, then only snapshots whose description equals database would be returned. Filter values are case sensitive. We support only exact string matching, or substring matching (with wildcards).
Tip
Your search can include the literal values of the wildcard characters; you just need to escape them with a backslash before the character. For example, a value of \*amazon\?\\ searches for the literal string *amazon?\.
Listing Resources
You can list your resources using the console, command-line interface, or API actions.
API
Each resource type has a corresponding API action that you use to list resources of that type. For example, you can use the DescribeImages action to list your images, and the DescribeInstances action to list your instances. The following example uses DescribeInstances to list your instances.
https://ec2.amazonaws.com/?Action=DescribeInstances &AuthParams
Filtering Resources
You can filter a list of your resources using the console, command-line interface, or API actions.
Tip
If you're using the command line tools on Windows, you might need to use quotation marks as shown here. The following example uses filters so that ec2-describe-volumes lists only volumes that are in the us-east-1b Availability Zone and have a status of available.
PROMPT> ec2-describe-volumes --filter "availability-zone=us-east-1b" --filter "status=available"
The following example uses filters so that ec2-describe-images lists only public 64-bit Windows AMIs that use an Amazon EBS volume as the root device.
PROMPT> ec2-describe-images --filter "is-public=true" --filter "architec ture=x86_64" --filter "platform=windows"
The following example uses filters so that ec2-describe-instances lists only your m1.small or m1.large instances that have an attached Amazon EBS volume that is set to delete on instance termination.
PROMPT> ec2-describe-instances --filter "instance-type=m1.small" --filter "in stance-type=m1.large" --filter "block-device-mapping.status=attached" --filter "block-device-mapping.delete-on-termination=true"
For an example of filtering resources by tags, see Tagging Your Amazon EC2 Resources (p. 566).
API
You can add one or more filters to a DescribeXXX action to scope the results to resources that match certain criteria. For a list of the available filters for a given EC2 resource, go to the DescribeXXX topic for that resource in the Amazon Elastic Compute Cloud API Reference. The following example request uses filters with DescribeVolumes to list only your volumes that are in the us-east-1b Availability Zone and have a status of available.
https://ec2.amazonaws.com/?Action=DescribeVolumes &Filter.1.Name=availability-zone &Filter.1.Value.1=us-east-1b &Filter.2.Name=status &Filter.2.Value.1=available &AUTHPARAMS
The following example request uses filters with DescribeImages to list only public 64-bit Windows AMIs that use an Amazon EBS volume as the root device.
https://ec2.amazonaws.com/?Action=DescribeImages &Filter.1.Name=is-public &Filter.1.Value.1=true &Filter.2.Name=architecture &Filter.2.Value.1=x86_64 &Filter.3.Name=platform &Filter.3.Value.1=windows &AUTHPARAMS
The following example request uses filters with DescribeInstances to list only the m1.small or m1.large instances that have an attached Amazon EBS volume that is set to delete on instance termination.
https://ec2.amazonaws.com/?Action=DescribeInstances &Filter.1.Name=instance-type &Filter.1.Value.1=m1.small &Filter.1.Value.2=m1.large &Filter.2.Name=block-device-mapping.status &Filter.2.Value.1=attached &Filter.3.Name=block-device-mapping.delete-on-termination &Filter.3.Value.1=true &AUTHPARAMS
For an example of filtering resources by tags, see Tagging Your Amazon EC2 Resources (p. 566).
Tag Basics
Each tag consists of a key and a value, both of which you define. For example, you could define a set of tags for your account's instances that helps you track each instance's owner and stack level. The following diagram illustrates the tag concept. In this example, you've assigned two tags to each of your instances, one called Owner and another called Stack. Each of the tags also has an associated value.
Tags enable you to categorize your AWS resources in different ways, for example, by purpose, owner, or environment. We recommend that you devise a set of tag keys that meets your needs for each resource type. Using a consistent set of tag keys makes it easier for you to manage your resources.You can search and filter the resources based on the tags you add. We don't apply any semantic meaning to your tags; we interpret a tag strictly as a string of characters. Also, we don't automatically assign tags to your resources. You can work with tags using the AWS Management Console, the Amazon EC2 command line interface, and the Amazon EC2 API actions.
Note
The AWS Management Console is designed to let you add, edit, or remove tags from one resource at a time, whereas the command line interface and the API actions let you work with the tags for multiple resources in a single call. You can assign tags only to resources that already exist. Exception: You can add tags when you launch an instance in the AWS Management Console. If you add a tag that has the same key as an existing tag on that resource, the new value overwrites the old value. You can edit tag keys and values, and you can remove tags from a resource at any time. You can set a tag's value to the empty string, but you can't set a tag's value to null. If you're using AWS Identity and Access Management (IAM), you can control which users in your AWS Account have permission to create, edit, or delete tags. For more information about IAM, see AWS Identity and Access Management (p. 9).
Tag Restrictions
The following basic restrictions apply to tags: Maximum number of tags per resource10 Maximum key length128 Unicode characters Maximum value length256 Unicode characters Tag keys and values are case sensitive. Do not use the aws: prefix in your tag names or values, as it is reserved for AWS use. You can't edit or delete tag names or values with this prefix. You can't terminate, stop, or delete a resource based solely on its tags; you must specify the resource identifier. For example, to delete snapshots that you tagged with a tag key called DeleteMe, you must
Amazon Elastic Compute Cloud User Guide Tagging Your Resources for Billing
first get a list of those snapshots using DescribeSnapshots with a filter that specifies the tag. Then you use DeleteSnapshots with the IDs of the snapshots (for example, snap-1a2b3c4d). You can't call DeleteSnapshots with a filter that specified the tag. For more information about using filters when listing your resources, see Listing and Filtering Your Resources (p. 562). You can tag public or shared resources, but the tags you assign are available only to your AWS account and not to the other accounts sharing the resource.
Displaying Tags
When you select a page in the Amazon EC2 console, it displays a list of the related resources. For example, when you select Instances from the navigation pane, the console displays a list of instances. When you select a resource from one of these lists, if the resource supports tags, the details pane includes a Tags tab that you can use to manage its tags. The following image shows the Tags tab for an instance with two tags: "Name = DNS Server" and "Purpose = Network Management".
You can add a column to the resource list that displays all values for tags with the same key. This column enables you to sort and filter the resource list by the tag. On the Tags tab, click Show Column for the tag. The tag appears in the resource list as a new column.
Amazon Elastic Compute Cloud User Guide Using the AWS Management Console
To delete a tag
1. 2. 3. Select the resource from the resource list. Select the Tags tab in the details pane. Click Remove Tag in the Actions column for the tag.
Amazon Elastic Compute Cloud User Guide Using the AWS Management Console
5. 6. 7.
On the CREATE A KEY PAIR page, you can choose from any existing key pairs that you've created, or follow the wizard directions to create a new key pair. On the Configure Firewall page, you can choose from any existing security group that you own, or follow the wizard directions to create a new security group. Review your settings. When you're satisfied with your selections, click Launch.
5.
Review your settings. When you're satisfied with your selections, click Launch.
Amazon Elastic Compute Cloud User Guide Using the Command Line Interface
a. b. c.
Select one of the resources. Select the Tags tab in the details pane. Locate the tag in the list and click Show Column.
2.
Click the filter icon in the top right corner of the column for the tag to display the filter list.
3.
Select the tag values, and then click Apply Filter to filter the results list.
In the following sections, we demonstrate how you can list tags, or list resources and filter the results based on tags. Topics
Amazon Elastic Compute Cloud User Guide Using the Command Line Interface
Adding Tags (p. 572) Listing Tags (p. 572) Changing Tag Values (p. 573) Deleting Tags (p. 573) Filtering the List of Resources by Tags (p. 573)
Adding Tags
The following example adds the same two tags to an AMI and an instance. For the first tag, the key is webserver and there is no value. For the other tag, the key is stack and the value is Production.
PROMPT> ec2-create-tags ami-1a2b3c4d i-6f5d4e3a --tag webserver --tag stack=Production TAG ami-1a2b3c4d image webserver TAG ami-1a2b3c4d image stack Production TAG i-6f5d4e3a image webserver TAG i-6f5d4e3a image stack Production
Listing Tags
You can list your tags and filter the results in different ways, as shown in the following examples. This example describes all your tags.
PROMPT> ec2-describe-tags TAG ami-1a2b3c4d image webserver TAG ami-1a2b3c4d image stack Production TAG i-5f4e3d2a instance webserver TAG i-5f4e3d2a instance stack Production TAG i-12345678 instance database_server TAG i-12345678 instance stack Test
This example describes the tags for your resource with ID ami-1a2b3c4d.
PROMPT> ec2-describe-tags --filter "resource-id=ami-1a2b3c4d" TAG ami-1a2b3c4d image webserver TAG ami-1a2b3c4d image stack Production
This example describes the tags for all your instances that have a tag with the key webserver.
PROMPT> ec2-describe-tags --filter "resource-type=instance" --filter "key=web server" TAG i-5f4e3d2a instance webserver
Amazon Elastic Compute Cloud User Guide Using the Command Line Interface
This example describes the tags for all your instances that have a tag with the key stack and a value of either Test or Production.
PROMPT> ec2-describe-tags --filter "resource-type=instance" --filter "key=stack" --filter "value=Test" --filter "value=Production" TAG i-5f4e3d2a instance stack Production TAG i-12345678 instance stack Test
This example describes the tags for all your instances that have a tag with the key Purpose and no value.
PROMPT> ec2-describe-tags --filter "resource-type=instance" --filter "key=Pur pose" --filter "value="
Deleting Tags
The following example deletes the tags that you originally assigned to the AMI and instance.
PROMPT> ec2-delete-tags ami-1a2b3c4d i-6f5d4e3a --tag webserver --tag stack
Notice that you didn't need to specify a value. If you specify a value, the tag is deleted only if its value matches the one you specified. If you specify an empty string as the value, the tag is deleted only if the tag's value is an empty string. The following example specifies an empty string as the value for the tag to delete (notice the equals sign after Owner).
PROMPT> ec2-delete-tags snap-1a2b3c4d --tag Owner=
Amazon Elastic Compute Cloud User Guide Using the API Actions
Purpose Project2 Owner TeamB Purpose Logs Owner TeamC Purpose Project1 Owner TeamC Purpose Project2 Owner TeamC Purpose Logs
Alternatively, you can get volume descriptions and filter the results by tag. The filter name you use is tag:key. To get a list of just the volumes belonging to either TeamA or TeamB that contain log data, use ec2-describe-volumes with a filter based on the tags of interest. You can use a wildcard to find the volumes that have a tag with the Purpose key that have a value that contains Log.
PROMPT> ec2-describe-volumes --filter tag:Owner=TeamA --filter tag:Owner=TeamB --filter tag:Purpose=*Log* VOLUME vol-4562dabf 5 us-east-1b available 2010-02-22T22:50:43+0000 Owner TeamA Purpose RawLogData VOLUME vol-3b3a4c4d 12 us-east-1b available 2010-05-01T13:09:27+0000 Owner TeamB Purpose Logs
In the following sections, we demonstrate how you can list tags, or list resources and filter the results based on tags. Topics Filtering a List of Tags by Resource (p. 574) Filtering a List of Resources by Tag (p. 577)
Amazon Elastic Compute Cloud User Guide Using the API Actions
Amazon Elastic Compute Cloud User Guide Using the API Actions
</item> <item> <resourceId>vol-9f8g7d6c</resourceId> <resourceType>volume</resourceType> <key>Owner</key> <value>TeamB</value> </item> <item> <resourceId>vol-9f8g7d6c</resourceId> <resourceType>volume</resourceType> <key>Purpose</key> <value>Project2</value> </item> <item> <resourceId>vol-3b3a4c4d</resourceId> <resourceType>volume</resourceType> <key>Owner</key> <value>TeamB</value> </item> <item> <resourceId>vol-3b3a4c4d</resourceId> <resourceType>volume</resourceType> <key>Purpose</key> <value>Logs</value> </item> <item> <resourceId>vol-1234abcd</resourceId> <resourceType>volume</resourceType> <key>Owner</key> <value>TeamC</value> </item> <item> <resourceId>vol-1234abcd</resourceId> <resourceType>volume</resourceType> <key>Purpose</key> <value>Project1</value> </item> <item> <resourceId>vol-7f7g7d7a</resourceId> <resourceType>volume</resourceType> <key>Owner</key> <value>TeamC</value> </item> <item> <resourceId>vol-7f7g7d7a</resourceId> <resourceType>volume</resourceType> <key>Purpose</key> <value>Project2</value> </item> <item> <resourceId>vol-4a4b4c4d</resourceId> <resourceType>volume</resourceType> <key>Owner</key> <value>TeamC</value> </item> <item> <resourceId>vol-4a4b4c4d</resourceId> <resourceType>volume</resourceType>
Amazon Elastic Compute Cloud User Guide Using the API Actions
Because of the filtering, the response includes only two of the volumes that were in the preceding list of tagged volumes. The volume's tags are included in the response.
<DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/2013-02-01/"> <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId> <volumeSet> <item> <volumeId>vol-4562dabf</volumeId> <size>5</size> <snapshotId/> <availabilityZone>us-east-1b</availabilityZone> <status>available</status> <createTime>2010-02-22T22:50:43+0000</createTime> <attachmentSet/> <tagSet> <item> <key>Owner</key> <value>TeamA</key> </item> <item> <key>Purpose</key> <value>RawLogData</key> </item> </tagSet> </item> <item> <volumeId>vol-3b3a4c4d</volumeId> <size>12</size> <snapshotId/> <availabilityZone>us-east-1b</availabilityZone> <status>available</status>
Amazon Elastic Compute Cloud User Guide Using the API Actions
<createTime>2010-05-01T13:09:27+0000</createTime> <attachmentSet/> <tagSet> <item> <key>Owner</key> <value>TeamB</key> </item> <item> <key>Purpose</key> <value>Logs</key> </item> </tagSet> </item> </volumeSet> </DescribeVolumesResponse>
Amazon Elastic Compute Cloud User Guide Download the Command Line Tools (API Tools)
Some additional setup is required before you can use the tools. These steps are discussed next.
Overview
The first step is to establish trust with the software publisher: download the public key of the software publisher, check that the owner of the public key is who they claim to be, and then add the public key to your keyring. Your keyring is a collection of known public keys. You can then explicitly trust the public key, or trust it implicitly because the public key is trusted by someone with whom you have a pre-existing trust relationship. After you've established the authenticity of the public key, you can use it to verify the signature of the application. Using security tools, you'll calculate a signature from the publisher's public key and your downloaded copy of the application. If the calculated signature matches the signature the software developer has published for the application, you can have confidence that the application has not been altered. Amazon EC2 command line tools are signed using GnuPG, an open implementation of the Pretty Good Privacy (OpenPGP) standard for secure digital signatures. GnuPG provides authentication and integrity checking through a 128-bit digital signature. Amazon EC2 publishes a public key and signatures you can use to verify the downloaded Amazon EC2 command line tools. For more information about PGP and GnuPG (GPG), go to http://www.gnupg.org.
Amazon Elastic Compute Cloud User Guide Authenticate the Public Key
In addition to installing pre-compiled implementations of GnuPG, you can also download and compile the source code from http://gnupg.org/download/index.en.html. After you have installed a set of GPG tools, use them to create a public-private key set. You'll need this later to sign changes to your trust status. If you have previously installed the GPG tools and already have a public-private key set, you can skip this step.
2.
Answer the questions that follow. You can use the suggested default values. Make a note of the passphrase you use to create the private key. You'll need this value later.
Note
This text file must use ASCII encoding. 2. Import the EC2 Packages public key into your keyring using the following command in the directory where you saved the file ec2-packages-public.key.
API Version 2013-02-01 581
Amazon Elastic Compute Cloud User Guide Authenticate the Public Key
The command returns results similar to the following. Make a note of the key value; you'll need it in the next step. In the example below, the key value is 0349E66A.
pg: key 0349E66A: public key "AWS EC2 Packages <ec2-packages@amazon.com>" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 2 signed: 1 trust: 0-, 0q, 0n, 0m, 0f, 2u gpg: depth: 1 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 1f, 0u gpg: next trustdb check due at 2014-07-20
3.
Verify the fingerprint by running the following command, where key-value is replaced by the value from the previous step.
gpg --fingerprint key-value
This command returns results similar to the following. Compare the key fingerprint to that published on EC2 Packages Public Key. They should match. If they don't, do not continue to install the tools, and contact Amazon Web Services.
pub 4096R/0349E66A 2011-04-04 Key fingerprint = A262 37CF 2294 C30E 9844 96C9 116B 3651 0349 E66A uid AWS EC2 Packages <ec2-packages@amazon.com>
4.
If the fingerprint matches the one published on the aws.amazon.com website, you may choose to trust EC2 Packages public key. To do so, run the following command, where key-value is replaced by the key value from Step 2.
gpg --edit-key key-value
The GPG tools ask you to establish a level of trust for EC2 Packages, with a prompt such as the following. To learn more about these trust options, go to the The GNU Privacy Handbook.
Please decide how far you trust this user to correctly verify other users' keys (by looking at passports, checking fingerprints from different sources, etc.) 1 2 3 4 5 m = = = = = = I don't know or won't say I do NOT trust I trust marginally I trust fully I trust ultimately back to the main menu
Amazon Elastic Compute Cloud User Guide Verify the Signature of the Package
Your decision?
Type 4 and press the Enter key. 5. Sign the key with your private key (created when you installed the GPG tools) to set the new trust level. Do this using the following command.
sign
6.
You are asked to confirm, type y, and press the Enter key. You are asked for the passcode that you used when you created your private key. Type your passcode and press the Enter key. Save your changes using the following command.
save
This saves your changes to the keyring. It should also exit the PGP session. If it doesn't, press CTRL+Z to exit the PGP session and return to the main terminal.
3.
If the output contains the phrase 'Good signature from "AWS EC2 Packages <ec2-packages@amazon.com>"' the signature has successfully been verified, and you can proceed to unzip and install the Amazon EC2 command line tools. If the output includes the phrase "BAD signature", check that you performed the procedure correctly. If you continue to get this response, contact Amazon Web Services and do not unzip or install the file that you downloaded.
Amazon Elastic Compute Cloud User Guide Tell the Tools Where Java Lives
Note that this location can be a symlink rather than the actual directory location. You can't use a symlink in an environment variable. In the default installation of Mac OS, Java is installed in /Library/JAVA/Home. If you installed Java manually, Java might be located elsewhere. For more information about setting this variable on a Mac, see Unable to find a $JAVA_HOME. Set JAVA_HOME to the full path of the Java home directory. For example, if your Java executable is in /usr/bin, set JAVA_HOME to /usr, as shown here.
$ export JAVA_HOME=/usr
2.
Note
The export command applies only to the current shell session. To permanently create or update an environment variable, include the command in a start-up script. For example, if you use Bash shell, you can include commands in your ~/.bashrc or /etc/profile file.
Note
If you are using Cygwin, JAVA_HOME should have a Windows path. 3. You can verify your JAVA_HOME setting using this command.
$ $JAVA_HOME/bin/java -version
If you've set the environment variable correctly, the output looks something like this.
java version "1.7.0_05" Java(TM) SE Runtime Environment (build 1.7.0_05-b05) Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode, sharing)
Amazon Elastic Compute Cloud User Guide Tell the Tools Where They Live
Note
If the path contains spaces, enclose it in quotes. For example, "C:\Program Files (x86)\Java\jre7". 2. You can verify your JAVA_HOME setting using this command:
C:\> %JAVA_HOME%\bin\java -version
If you've set the environment variable correctly, the output looks something like this:
java version "1.7.0_05" Java(TM) SE Runtime Environment (build 1.7.0_05-b05) Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode, sharing)
3.
Otherwise, check the setting of JAVA_HOME using the set command, fix any errors, and try the command again. Add the bin directory that contains the Java executable to your path before other versions of Java.
C:\> setx Path %JAVA_HOME%\bin;"%Path%"
4.
You can verify your update to the Path environment variable using this command:
C:\> java -version
You should see the same output as before. Otherwise, check the setting of Path, fix any errors, and try the command again.
Amazon Elastic Compute Cloud User Guide Tell the Tools Who You Are
Note
If you are using Cygwin, EC2_HOME must use Linux/UNIX paths (for example, /usr/bin instead of C:\usr\bin). Additionally, the value of EC2_HOME cannot contain any spaces, even if the value is quoted or the spaces are escaped. 2. You can update your PATH as follows.
$ export PATH=$PATH:$EC2_HOME/bin
2.
If you've set the environment variable correctly, you'll see output for the directory listing. If you get a File Not Found error, check the setting of EC2_HOME, fix any errors, and try the command again. 3. You can update your Path as follows.
C:\> setx Path "%PATH%";%EC2_HOME%\bin
Amazon Elastic Compute Cloud User Guide Verify the Tools Setup
5.
Under Access Credentials, on the Access Keys tab, your access key ID is displayed. To view your secret key, under Secret Access Key, click Show.
You can specify these credentials with the --aws-access-key and --aws-secret-key (or -O and -W) options every time you issue a command. However, it's easier to specify your access credentials using the following environment variables: AWS_ACCESS_KEYYour access key ID AWS_SECRET_KEYYour secret access key If these environment variables are set properly, their values serve as the default values for these required options, so you can omit them from the command line.
Note
Although we dont encourage it, for a limited time you can still use EC2_PRIVATE_KEY and EC2_CERT instead of AWS_ACCESS_KEY and AWS_SECRET_KEY. For more information, see Deprecated Options in Common Options for API Tools in the Amazon Elastic Compute Cloud CLI Reference. If you specify both sets of credentials, the command line tools use the access key ID and secret access key. On Linux and UNIX, you can set these environment variables as follows. These commands update the current shell session only. To permanently set these environment variables, include these commands in the start-up script for your shell.
$ export AWS_ACCESS_KEY=your_AWS_ACCESS_KEY_ID $ export AWS_SECRET_KEY=your_AWS_SECRET_KEY
The result shows the Region names and corresponding service endpoints. If you get an error that required option -O is missing, check the setting of AWS_ACCESS_KEY, fix any errors, and try the command again. If you get an error that required option -W is missing, check the setting of AWS_SECRET_KEY, fix any errors, and try the command again.
Required Knowledge
If you plan to access Amazon EC2 through an API, you should be familiar with the following: XML Web services HTTP requests One or more programming languages, such as Java, PHP, Perl, Python, Ruby, C#, or C++.
Endpoints
An endpoint is a URL that serves as an entry point for a web service. You can select a regional endpoint for Amazon EC2 when you make your requests to reduce latency. For more information about regions, see Region and Availability Zone Concepts (p. 119). For information about the endpoints for Amazon EC2, see Regions and Endpoints in the Amazon Web Services General Reference. If you specify the general endpoint, ec2.amazonaws.com, we use the endpoint for us-east-1. To use a different region, specify its associated endpoint. For example, if you specify ec2.us-west-2.amazonaws.com as the endpoint, we direct your request to the us-west-2 endpoint.
Available Libraries
AWS provides libraries, sample code, tutorials, and other resources for software developers who prefer to build applications using language-specific APIs instead of submitting a request over HTTP or HTTPS. These libraries provide basic functions such as request authentication, request retries, and error handling so that it is easier to get started. Libraries and resources are available for the following languages: Java PHP Python Ruby Windows and .NET For libraries and sample code in all languages for Amazon EC2, see http://aws.amazon.com/code/Amazon-EC2. For libraries and sample code in all languages in Amazon Web Services, see Sample Code & Libraries.
Query Requests
Query requests are HTTP or HTTPS requests that use the HTTP verb GET or POST and a Query parameter named Action. Topics Structure of a GET Request (p. 590) Query Parameters (p. 591) Query API Authentication (p. 592) Query Response Structures (p. 592)
Tip
Because the GET requests are URLs, you must URL encode the parameter values. In the Amazon EC2 documentation, we leave the example GET requests unencoded to make them easier to read. The URL consists of the following: Endpoint The URL that serves as the entry point for the web service Action The action that you want to perform (for example, use RunInstance to run an instance) Parameters Any parameters for the request; each parameter is separated by an ampersand (&). The following is an example request that launches instances.
To make these example requests even easier to read, the Amazon EC2 documentation presents them in the following format.
https://ec2.amazonaws.com/?Action=RunInstances &ImageId=ami-60a54009 &MaxCount=3 &MinCount=1 &Placement.AvailabilityZone=us-east-1b &Monitoring.Enabled=true &AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE &Version=2013-02-01 &Expires=2010-10-10T12:00:00Z &Signature=lBP67vCvGlDMBQ1dofZxg8E8SUEXAMPLE &SignatureVersion=2 &SignatureMethod=HmacSHA256
The first line specifies the endpoint of the request. After the endpoint is a question mark (?), which separates the endpoint from the parameters. The Action parameter indicates the action to perform. For a complete list of actions, see Actions in the Amazon Elastic Compute Cloud API Reference. The remaining lines specify additional parameters for the request.
Query Parameters
Each Query request must include required common parameters to handle authentication and selection of an action. For more information, see Common Query Parameters in the Amazon Elastic Compute Cloud API Reference. Some operations take lists of parameters. These lists are specified using the param.n notation, where n is an integer starting from 1. The following example adds multiple devices to a block device mapping using a list of BlockDeviceMapping parameters.
http://ec2.amazonaws.com/?Action=RunInstances &ImageId.1=ami-72aa081b ... &BlockDeviceMapping.1.DeviceName=/dev/sdj &BlockDeviceMapping.1.Ebs.NoDevice=true &BlockDeviceMapping.2.DeviceName=/dev/sdh &BlockDeviceMapping.2.Ebs.VolumeSize=300 &BlockDeviceMapping.3.DeviceName=/dev/sdc &BlockDeviceMapping.3.VirtualName=ephemeral1 &AUTHPARAMS
Tip
In the example Query requests we present in the Amazon EC2 documentation, we omit the parameters related to authentication to make it easier for you to focus on the parameters for the action. We replace them with the following literal string to remind you that you must include these parameters in your request: &AuthParams.
SOAP Requests
We have deprecated the SOAP API for Amazon EC2, and will end support for it in 2013.
Technical FAQ
Topics General Information FAQ (p. 593) Instances and AMIs Information FAQ (p. 594) Operation Information FAQ (p. 595) Instance Types and Architectures FAQ (p. 596) IP Information FAQ (p. 598) Region and Availability Zone FAQ (p. 600) Windows Instances FAQ (p. 602) Monitoring, Errors, and Unexpected Behavior FAQ (p. 602) Reserved Instances FAQs (p. 603) Paid AMIs FAQ (p. 605) Error Messages FAQ (p. 606) Miscellaneous FAQ (p. 607) This section contains answers to commonly asked questions. For additional questions, see Amazon EC2 FAQs and Amazon EC2 Technical FAQs.
Amazon Elastic Compute Cloud User Guide Instances and AMIs Information FAQ
If you need faster launch times, consider using AMIs backed by Amazon EBS. Q: Can I get a bigger/smaller/differently optimized virtual machine? Yes. For more information, see Instance Families and Types (p. 89). Q: Is there a REST interface to Amazon EC2? Not at present. You can use the Query API, SOAP API, or the command line tools. Q: How does Amazon EC2 handle load balancing? With a service as flexible as Amazon EC2, you can use many types of load balancing systems. The load balancing instances can forward traffic to other systems. There are several open source solutions that are in wide use. Q: Does Amazon perform system maintenance? Yes. Periodically, Amazon might perform maintenance that requires a reboot of your system. Make sure your instances can recover and restart after being rebooted.
You are not charged for additional instance hours while the instance is in a stopped state. A full instance hour will be charged for every transition from a stopped state to a running state, even if this happens multiple times within a single hour. If the instance type was changed while the instance was stopped, you will be charged at the new instance types rate after the instance is started. All of the associated Amazon EBS usage of your instance, including root device usage, are billed using the typical Amazon EBS prices. Q: What can I do with a stopped instance? You can attach or detach Amazon EBS volumes. You can use the CreateImage action to create an AMI from the instance. You can change the kernel, RAM disk, and instance type with the ModifyInstanceAttribute action. You can restart the instance with the StartInstances action, and terminate the instance with the TerminateInstances action. Q: What limitations exist for stopped instances? In addition to the limit on running instances, there is an additional limit on the overall number of instances that you can have (whether running, stopped, or in any other state except for terminated.) This overall instance limit is 2 times your running instance limit. The running instance limit can be increased upon request using the instance limit request form. Q: Do I need to share the Amazon EBS snapshots that an AMI references in order to share the AMI? No, only the AMI itself needs to be shared. The system will automatically provide the instance access to the referenced Amazon EBS snapshots for the purposes of the launch. Q: How can I control how block devices are exposed to my instance? See Block Device Mapping (p. 545).
Amazon Elastic Compute Cloud User Guide Instance Types and Architectures FAQ
Because there is no way to ensure that shutdown scripts run, you should be prepared to deal with abnormal terminations. Q: How can I allow other people to launch my AMI? You can allow other AWS accounts to launch your AMI by modifying the its launchPermission attribute. You can grant public launch permissions or explicit permissions to specific AWS accounts. For more information, see Sharing AMIs Safely (p. 61). Q: Why do I need to reregister a rebundled Amazon EC2 instance store-backed AMI? Can I keep the same AMI ID? An AMI ID is associated with the physical bits in an image. To protect users from images being modified, we require you to reregister Amazon EC2 instance store-backed AMIs after rebundling. Q: How can I push an Amazon S3 object to an Amazon EBS volume? You can push an Amazon S3 object to an Amazon EBS volume by mounting the Amazon EBS volume on an Amazon EC2 instance and then using a data transfer application (for example, FTP/SFTP, SCP) on your running instance to transfer the data. Q: Can I pass JVM properties to the command line tools? Yes. By setting the environment variable EC2_JVM_ARGS, you can pass arbitrary JVM properties to the command line tools. Q: Can I use a proxy with the command line tools? Yes. By passing JVM properties through the EC2_JVM_ARGS environment variable, you can specify proxy settings for the command line tools. For example, in Linux and UNIX:
export EC2_JVM_ARGS="-Dhttps.proxyHost=my.proxy.com -Dhttps.proxyPort=8080"
The following table describes the properties for configuring a proxy. Setting https.proxyHost https.proxyPort http.proxyHost http.proxyPort http.proxyRealm http.proxyUser http.proxyPass Description HTTPS proxy host HTTPS proxy port HTTP proxy host HTTP proxy port Proxy realm (HTTPS and HTTP) Proxy user name (HTTPS and HTTP) Proxy password (HTTPS and HTTP)
You should use https.proxyHost when EC2_URL specifies an HTTPS host, and http.proxyHost when EC2_URL specifies an HTTP host.
Amazon Elastic Compute Cloud User Guide Instance Types and Architectures FAQ
The original instance type is still available. It is called the small instance (m1.small) and it has the same technical specifications. Q: Will the original instance type be retired soon? There are no plans to retire the original instance type. Q: If I do not specify an instance type at launch, what type of instance do I get? You will get the smallest instance type available for the type of AMI you selected. Q: Does my instance limit apply to all instance types or is there a separate limit for each type? The instance limit applies to the sum of all instances, regardless of type. There is no separate instance limit per type. Q: Can I mix instance types, or do I have to use the same type for all of my instances? You can launch any combination of instance types. Choose the instance types that have the most appropriate memory, CPU, and storage for each function within your application. Q: How do I select the right instance type? Amazon EC2 instances are grouped into several families. For more information, refer to Instance Families and Types (p. 89).
Tip
One of the advantages of Amazon EC2 is that you pay by the instance hour, which makes it convenient and inexpensive to test the performance of your application on different instance families and types. A good way to determine the most appropriate instance family and instance type is to launch test instances and benchmark your application. Q: When should I use High-CPU instance types (c1.medium and c1.xlarge)? High-CPU instance types have a proportionately higher ratio of CPU to memory and are well suited for compute-intensive applications. To determine whether they are appropriate for you, launch an instance and benchmark your own application on different instance types and calculate which is most appropriate. Q: Which instance types are 32-bit and which are 64-bit? All instance types can run 64-bit AMIs. The micro (t1.micro), small (m1.small), medium (m1.medium), and High-CPU medium (c1.medium) instances can also run 32-bit AMIs. Q: Can I launch any AMI on any type of instance? No. Cluster compute (cc1.4xlarge and cc2.8xlarge) and cluster graphics (cg1.4xlage) instances can only run HVM AMIs. All other instances can run Windows HVM or Linux/UNIX paravirtualized AMIs. Q: Can I use my own kernel? Yes. For more information, see Enabling Your Own Linux Kernels (p. 80). Q: Do I have to do anything special to bundle the large or extra large Amazon EC2 instance store-backed instances? Make sure to use the latest AMI Tools. Q: Can I build an AMI that works on both 32-bit and 64-bit instances? No, an AMI is either a 32-bit AMI or a 64-bit. Q: Can I run 32- bit applications on 64-bit AMIs?
API Version 2013-02-01 597
You can run a 32-bit application on a 64-bit host if the Linux/UNIX kernel is compiled with IA32 emulation and the correct 32-bit libraries are available. By default, the Amazon DomU Kernel has IA32 emulation enabled and there are many public AMIs that include preinstalled 32-bit libraries. If the library you require is not included with the AMI, you can install it using standard tools (for example, yum). Q: How does I/O performance of an instance store compare to the I/O performance of an EBS volume? The instance stores on large and extra large instances have higher and more consistent I/O performance than the original (small) instance. Amazon EBS volumes perform consistently for all instance types. The first write to any given block of the disk will be slower than subsequent writes. For more information, see Disk Performance Optimization (p. 543) Q: Can I RAID the spindles exposed on large and extra large instances? Yes, you can use software RAID on top of the exposed spindles. The initial RAID setup might take a long time. For more information, see Disk Performance Optimization (p. 543)
IP Information FAQ
Q: How do I host a public domain if I use DHCP to obtain an IP address? You can use a dynamic DNS service, such as DynDNS or ZoneEdit. Alternatively, you can map an Elastic IP address to your instance and avoid the propagation delays possible with a dynamic DNS solution. Q: Why do I get an internal (RFC 1918) IP address when I look up a DNS name that I expect to map to my instance's external IP address? The Amazon EC2 DNS servers return the internal IP address when asked about an instance's public DNS name. In this way, DNS lookups that would resolve to a public Amazon EC2 IP address will be translated to the correct internal IP address. This only works when using the Amazon EC2 DNS servers from an Amazon EC2 instance. Q: Why is Amazon EC2 using NAT? Public IP space is a limited resource. Amazon EC2 is adopting NAT to ensure that we are able to efficiently make use of our public Internet addresses. Furthermore, the new NAT networking will enable Amazon to deliver new features in the future. For example, some users might not want external addresses. This would allow for non-Internet routable clusters, which will further preserve IPs and increase security for those not running public facing servers. Q: Can I use a static IP in my instances? Not at present. Your image must be configured as a DHCP client and it will be assigned an IP address. Currently, all instances come with Internet- addressable IP addresses. If you enable access through the firewall from the "world", you can address them from anywhere. Q: How does the instance know its public and private addresses? From within the instance, issue the following HTTP queries: To obtain the internal IP address:
curl http://169.254.169.254/latest/meta-data/local-ipv4
Q: Why am I limited to 5 Elastic IP addresses? Public (IPV4) Internet addresses are a scarce public resource. Amazon EC2 is committed to helping use that space efficiently. By default, all accounts are limited to 5 Elastic IP addresses. If you need more than 5 Elastic IP addresses, please complete the Amazon EC2 Elastic IP Address Request Form. We will ask you to think through your use case and help us understand your need for additional addresses. Q: Is my Elastic IP addressed fixed to a single instance? Unlike a traditional dedicated IP address, an Elastic IP address can be assigned to many different instances over time. Q: Is there a minimum usage required for Elastic IP addresses? When operating within the 5 address limit, you can leave addresses unattached as you need. However, we reserve the right to reclaim Elastic IP addresses that are chronically underutilized. Q: Is there a charge for Elastic IP addresses? You are not charged for a single Elastic IP (EIP) address on a running instance . If you associate additional EIPs with that instance, you will be charged for each additional EIP associated with that instance per hour (prorated). Additional EIPs are only available in Amazon VPC. To ensure efficient use of Elastic IP addresses, we impose a small hourly charge when these IP addresses are not associated with a running instance, or when they are associated with a stopped instance or an unattached network interface. You can associate an Elastic IP address to an elastic network interface (ENI); however, if that ENI is not attached to an instance, youll be charged for the Elastic IP address. To avoid charges for Elastic IP addresses that you are not using, use ReleaseAddress. Q: Do I need one Elastic IP address for each instance that I have running? No. By default, every instance comes with a private IP address and an Internet routable public IP address. These addresses are fixed for the life of the instance (exception: Amazon EBS-backed instances typically change IP addresses when you stop and restart them). We believe the private and public IP addresses should be adequate for many applications where you do not need a long lived Internet routable end point (for example, compute clusters, web crawling, and back-end services). Q: What happens to an Elastic IP address if I stop the instance associated with it? The Elastic IP address is disassociated from the instance when an EC2 instance is stopped. In Amazon VPC, when an instance is stopped, the Elastic IP address remains associated with the instance. Q: Why don't you use IPV6 addresses? Because of the scarcity of IPV4 Internet address, Amazon EC2 will be actively investigating the use of IPV6 addresses. We believe this is the only tenable long term solution. We don't yet have a timeline for introducing IPV6 addresses. Q: Can I launch an instance with no public IP address?
Amazon Elastic Compute Cloud User Guide Region and Availability Zone FAQ
You cannot currently launch an instance without a public IP address. We understand that for many applications, it is desirable to have no Internet routable IP address (for example, internal databases).
Note
Instances you launch into a VPC do not have a public IP address by default. For more information about Amazon Virtual Private Cloud, go to the Amazon Virtual Private Cloud Getting Started Guide. Q: How long does it take to remap an Elastic IP address? After you successfully remap an IP address, it usually occurs within a few minutes. Q: Will I be charged for the time when my IP address is unattached because my instance failed? You are not charged until your Elastic IP address has been unattached for a full hour. As long as you are monitoring your instances, you will have plenty of time to reattach your instance before the charge is metered. Q: Am I limited to 100 Elastic IP remaps per month? No. The first 100 remaps per month per account are free. After you reach this limit, you'll be charged for each additional remap. Q: Can I configure the reverse DNS record for my Elastic IP address? Yes, you can configure the reverse DNS record of your Elastic IP address (submit the Request to Remove Email Sending Limitations form). Note that a corresponding forward DNS record pointing to that Elastic IP address must exist before we can create the reverse DNS record.
For more information, see Specifying the Region to Use (p. 123). Q: How do I launch an AMI in another region? For Amazon EC2 instance store-backed AMIs: Copy your AMI from its current bucket to a bucket located in the region where you want to launch the AMI, and register the AMI. For example, to launch a US-based AMI in the EU region, copy the AMI to an Amazon S3 bucket that was created with an EU location
Amazon Elastic Compute Cloud User Guide Region and Availability Zone FAQ
constraint. After the AMI is copied, you must register the AMI and use the obtained AMI ID for launches in the new region. Also, make sure to give read access to the bucket, image manifest, and image parts to ec2-bundled-images@amazon.com for Windows AMIs, and za-team@amazon.com for Linux AMIs. Q: What tools are available to help migrate my AMIs to a new region? There's a command, ec2-migrate-image. This command is designed to help migrate AMIs to a new region. Run ec2-migrate-image --help for more details. Also go to Amazon Elastic Compute Cloud Command Line Reference. Q: Can I use the same SSH key pair across regions? This question refers only to the key pair used for SSH connections to the instance. Don't confuse this with your AWS Account ID and other credentials, which are global and work in all regions. The SSH key pairs that you create with the ec2-add-keypair command, the CreateKeyPair action, or the AWS Management Console work only in the region where you create them. However, you can optionally create an RSA key pair with a third-party tool and upload the public key to AWS. That key pair works in all regions. For more information, go to ec2-import-keypair in the Amazon Elastic Compute Cloud Command Line Reference or ImportKeyPair in the Amazon Elastic Compute Cloud API Reference. Q: Can instances use group-based firewall rules across regions? No. Group-based firewall rules only work within a region. If you need instances to communicate with each other across regions, you should use CIDR based firewall rules. To simplify IP address management, you can use firewall rules in combination with Elastic IP addresses.
Tip
Because inter-region traffic crosses the public Internet, encrypt all sensitive data. Q: How do I use the command line tools with multiple regions? By default, the command line tools use the original ec2.us-east-1.amazonaws.com endpoint (the us-east-1 region). For information about changing the region, see Specifying the Region to Use (p. 123). Q: What is the cost for data transfer between regions? Data transferred from one region to another is charged at both sides at the Internet data transfer rate. Q: Can I assume that my Availability Zone us-east-1a is the same location as someone else's Availability Zone us-east-1a? No. Currently, we do not support cross-account proximity. Each account's Availability Zones are independent. For example, the us-east-1a Availability Zone for one account might be in a different location than for another account. Q: How can I make sure that I am in the same Availability Zone as another developer? We do not currently support the ability to coordinate Availability Zones between AWS accounts. We are seeking customer feedback to understand the types of use cases for proximity control between accounts. We will use this feedback to determine how and when we might provide Availability Zone control between accounts. Q: Regional data transfer seems like such a small charge, why are you complicating my bill with this? We anticipate that for most common use cases, regional data transfer will only constitute a very small portion of your monthly usage charges. There are valid use cases that involve moving large amounts of data between Availability Zones. In these cases, the regional data transfer can be a significant cost.
API Version 2013-02-01 601
We try to enable as many use cases as possible while charging you only for what you use. Because of the large potential differences in the way developers could use regional data transfer, we think it is appropriate to break this cost out rather than amortize it across other charges. Q: If I have two instances in different Availability Zones, how will I be charged for regional data transfer? Each instance is charged for its data in and data out. Therefore, if data is transferred between these two instances, it is charged out for the first instance and in for the second instance. Q: If I transfer data between Availability Zones using public IP addresses, will I be charged twice for regional data transfer (once because it crosses Availability Zones, and once because I use public IP addresses)? No. Regional data transfer rates apply if at least one of the following cases is true, but are only charged once for a given instance even if both are true: The other instance is in a different Availability Zone, regardless of which type of address is used Public or Elastic IP addresses are used, regardless of which Availability Zone the other instance is in Q: Why are my Amazon EC2 resources not visible in the EU region or other region? Amazon EC2 Regions are isolated from each other. Resources such as SSH key pairs from a CreateKeyPair action, security groups, and AMIs are not replicated between regions. For more information, see Resource Locations (p. 560).
Amazon EC2 changes the state of your instance to running after your operating system starts booting. Depending on your AMI, there will be a delay before the instance is fully set up and functional. If your instance has been running for several minutes, verify whether you authorized the appropriate access to your host through the Amazon EC2 firewall. If you have launched your instances without specifying a security group, the default group is used. Permissions on the default group are very strict and disallow all access from the Internet and other groups. You need to modify the permissions of your default group or set up a new group with appropriate permissions. For more information, see Security Group Concepts (p. 426) If this doesn't solve your issue, make sure you authorized port 22 and try to open an SSH connection with verbose output. Refer to the documentation for your system for the exact syntax. For example, on Linux, the command is ssh -vv root@[hostname]. This output is very useful when you post to the forum. Q: Why did my instance terminate immediately after launch? Launch errors can be the result of an internal error during launch or a corrupt Amazon EC2 image. Internal errors are rare, as we actively test for and isolate suspect hosts. Consult the DescribeInstances action for details on why your instance failed to launch. The ec2-describe-instances command line tool does not provide this information. Use the -v option to read the detailed SOAP response and get detailed information. You can also attempt to launch the image again. If this proves to be a persistent problem (especially with a shared image), post to the AWS forums. Q: I ran shutdown from within an SSH session, but my instance still shows up as running when I query it with the DescribeInstances action, and I can't shell into it. To shut down an instance, use the TerminateInstances action or the ec2-terminate-instances command. You can also use shutdown -h, but you must verify the instance shutdown using the DescribeInstances action. Q: Why are my instances stuck in a pending state (or a shutting-down state)? This situation is rare and might be the result of a software error or misconfiguration. We actively monitor for this; please contact us if it occurs. Q: Why do I get an "AuthFailure: User is not AMI creator" error when I try to register an image? Make sure that you are using the correct user ID (AWS account ID) and certificate to create and upload the image. You must use the same ID and certificate to register the image with Amazon EC2.
The only difference is that with a Reserved Instance, you pay a low, one-time payment and receive a lower usage rate to run the instance than with an On-Demand Instance. Q: How do I purchase and start up a Reserved Instance? You purchase an EC2 Reserved Instance by calling the PurchaseReservedInstancesOffering action. Launching a Reserved Instance is no different than launching an On-Demand Instance.You simply use the RunInstances action or launch an instance using the AWS Management Console. Amazon EC2 will optimally apply the cheapest rate that you are eligible for in the background. Q: How do I control which instances are billed at the Reserved Instance rate? The RunInstances action does not distinguish between On-Demand and Reserved Instances. When computing your bill, our system automatically optimizes which instances are charged at the lower Reserved Instance rate to ensure you always pay the lowest amount. Q: How many Reserved Instances can I purchase? You can purchase up to 20 Reserved Instances per Availability Zone each month using the EC2 API. If you need additional Reserved Instances, complete the Registration Form. Q: Can a Reserved Instance that Ive bought for a particular instance type (for example, a High-CPU Extra Large Instance) be applied to a different instance type (for example, Standard Large Instance)? No. Each Reserved Instance is associated with a specific instance type, and can only be applied to that instance type for the duration of the Reserved Instance term. Q: Can I move a Reserved Instance from one region or Availability Zone to another? No. Each Reserved Instance is associated with a specific region and Availability Zone, which is fixed for the lifetime of the Reserved Instance and cannot be changed. Q: Do I need to specify an Availability Zone when I launch my instances in order to take advantage of my Reserved Instances? Yes. When you purchase a Reserved Instance you specify the Availability Zone in which you want to reserve that instance. In order to use that Reserved Instance, you need to ensure that you launch your instance in that same Availability Zone. Additionally, you can purchase a Reserved Instance in an Availability Zone where you already have a running instance, and the Reserved Instance will automatically get applied to that existing instance. Q: Can I cancel a Reserved Instance? The one-time payment for a Reserved Instance is not refundable. However, you can choose not to run or entirely stop using your Reserved Instance at any time, at which point you will not incur any further usage charges. Q: What happens when my Reserved Instances term comes to an end? Any instances that you have that are still running will continue to run, but will be charged at the standard On-Demand hourly rate. Q: When are Reserved Instances activated? A Reserved Instance is activated when your one-time payment has successfully been authorized. You can follow the status of your Reserved Instance on the AWS Account Activity page. Q: How can I assign an Elastic IP address to a Reserved Instance? You assign an Elastic IP address to a Reserved Instance in the same way that you assign an Elastic IP address to an on-demand instance. First, you acquire an Amazon EC2 Elastic IP address for your account,
API Version 2013-02-01 604
then you identify the instance to which you want to assign the Elastic IP address, and finally you associate it to your Reserved Instance. For more information, see Elastic IP Addresses (EIP) (p. 466).
If your customer uses AWS tools to rebundle the AMI, the product code associated with the AMI is inherited by the rebundled AMI. When launching the rebundled AMI the customer is still billed for usage based on your price.
Warning
This is a convenience feature and not a guarantee that the product code will always be attached to rebundled AMIs. Note that the customer's workflow could bundle the AMI outside of Amazon EC2, or the customer could use modified versions of the AWS tools, preventing the product code from being inherited. Q: Will the kernel/RAM disk be inherited by the rebundled AMI? If you rebundle an AMI, it inherits the kernel and RAM disk from the source AMI unless you specify a different kernel and RAM disk.
Warning
This is a convenience feature and not a guarantee that the kernel/RAM disk will always be attached to rebundled AMIs. Q: I created my paid AMIs with one AWS account, but I want to sell them using a different AWS account. Can I transfer them? No, you can't automatically transfer AMIs from one account to another. For AWS Marketplace, go to the AWS Marketplace Seller's Guide. For Amazon DevPay, you would have to upload the AMIs again using the second AWS account. Then you would register them with Amazon DevPay using the second account. Alternatively, you could leave the AMIs with the original account (the AMI owner account) and register them with Amazon DevPay using another AWS account (the product owner account).You could then use the AMI owner account to associate the product code with the AMIs. However, keep in mind that only the product owner (and not the AMI owner in this case) can use the ec2-confirm-product-instance command, which confirms that an instance is running an AMI associated with the product owner's product code. Q: How do I prevent someone from stripping the product code from my paid AMI? If you do not provide root access to your AMI, it cannot be rebundled. If you provide root access, our tools attempt to preserve the product code. To increase security, we recommend that you configure your application to check the instance metadata to verify that the product code is intact.
Q: Why can't I retrieve my instance-specific data from within a running instance when querying http://169.254.169.254/latest/meta-data/? The Parameterized Launches feature is available to instances that were launched after the feature was released. If you launched your instance before this, the data will not be available. If you want to use this functionality, relaunch your instances. If you still experience problems retrieving the data after relaunching your instance, check the following: Verify you are using the correct base URI (http://169.254.169.254/latest/meta-data/) Verify you are using the correct URI for the data you are trying to retrieve. Depending on the data, a trailing '/' might be required Verify you specified launch data when launching your instances. If not, you will get a HTTP error response (404) when trying to retrieve the user data Q: Why do I get keep getting "Request has expired" errors? To reduce the risk of replay attacks, our requests include a timestamp. This and the most important parts of the request are signed to ensure the message (including the timestamp) cannot be modified without detection. If the difference between the timestamp in the request and the time on our servers is larger than 5 minutes, the request is too old (or too new) and an error is returned. You need to ensure that your system clock is accurate and configured to use the correct time zone. For more information, go to NTP. Q: My instance is in a "running" state but shows 272 for its state code. What does that mean? This typically indicates some sort of issue with the host running the instance. First try rebooting the instance (through the AWS Management Console, or with the ec2-reboot-instances command or the RebootInstances) action. Caution: For Windows instances, this operation performs a hard reboot that might result in data corruption. If the reboot doesn't work, post a message to the EC2 forums with the instance ID. Typically someone from the EC2 team can get your instance back to a normal state. You can search for "code 272" in the forums and find previous messages others have posted.
Miscellaneous FAQ
Q: Are there any special requirements to use FTP? The File Transfer Protocol (FTP) has a PORT command by which a client sends its address back to the server. The server then connects to the client at that address to send the file data. If the client looks up its own internal address and sends this to the server, the connection will fail. In this specific case, there are two solutions to the problem. First, configure the client to send its public IP address. Second, the client can use "passive FTP" which makes connections only to the server, rather than from the server to the client. In general, applications which encode local addresses and port numbers in data sent to external servers might have problems with NAT. Care must always be taken to send the public address, rather than the internal one. We recommend using passive mode unless it is not supported by the FTP server.
Document History
The following table describes important additions to the Amazon EC2 documentation set. We also update the documentation frequently to address the feedback that you send us. Current API version: 2013-02-01. Feature High-memory cluster (cr1.8xlarge) instance type API Version Description Release Date
2012-12-01 Have large amounts of memory coupled with high 21 January CPU and network performance. These instances 2013 are well suited for in-memory analytics, graph analysis, and scientific computing applications. For more information, see Instance Families and Types (p. 89). 2012-12-01 High storage instances provide very high storage 20 density and high sequential read and write December performance per instance. They are well-suited for 2012 data warehousing, Hadoop/MapReduce, and parallel file systems. For more information, see High Storage Instances (p. 104). 2012-12-01 You can use snapshot copies to create backups of data, to create new Amazon EBS volumes, or to create Amazon Machine Images (AMIs). For more information, see Copying an Amazon EBS Snapshot (p. 524). 17 December 2012
Updated EBS metrics and status checks for Provisioned IOPS volumes
2012-10-01 Updated the EBS metrics to include two new 20 metrics for Provisioned IOPS volumes. For more November information, see Monitoring Volumes with 2012 CloudWatch (p. 508). Also added new status checks for Provisioned IOPS volumes. For more information, see Monitoring Volumes with Status Checks (p. 510).
API Version
Description
Release Date
2012-10-01 Amazon EC2 now provides you with several 19 pre-configured Windows Server 2012 AMIs. These November AMIs are immediately available for use in every 2012 Region and for every 64-bit instance type. The AMIs support the following languages: English Chinese Simplified Chinese Traditional Chinese Traditional Hong Kong Japanese Korean Portuguese Portuguese Brazil Czech Dutch French German Hungarian Italian Polish Russian Spanish Swedish Turkish
For more information, see Windows Instance Types (p. 94). Linux Kernels 2012-10-01 Updated AKI IDs; reorganized distribution kernels; 13 updated PVOps section. November 2012 2012-10-01 Added information to Adding Packages and the location of the latest Linux AMIs. For more information, see Adding Packages (p. 77). 02 November 2012
M3 Instances
2012-10-01 Added information about the new Amazon Elastic 31 October Compute Cloud (Amazon EC2) M3 extra-large and 2012 M3 double-extra-large instance types. For more information, see Instance Families and Types (p. 89). 14 October 2012
Amazon EC2 Spot 2012-10-01 Added information about Amazon EC2 Spot Instance Request Status Instance request status, which makes it easy to determine the state of your Amazon EC2 Spot requests.
Feature
API Version
Description
New Amazon Linux AMI 2012-08-15 Added information about the release of Amazon release Linux AMI 2012.09. For more information, see Amazon Linux AMIs (p. 73).
Amazon EC2 Reserved 2012-08-15 The Reserved Instance Marketplace matches 11 Instance Marketplace sellers who have Amazon EC2 Reserved Instances September that they no longer need with buyers who are 2012 looking to purchase additional capacity. Reserved Instances bought and sold through the Reserved Instance Marketplace work like any other Reserved Instances, except that they can have less than a full standard term remaining and can be sold at different prices. Provisioned IOPS 2012-07-20 Provisioned IOPS volumes deliver predictable, high 31 July (input/output operations performance for I/O intensive workloads, such as 2012 per second) for Amazon database applications, that rely on consistent and EBS fast response times. For more information, see EBS Volume Types (p. 485). High I/O instances for Amazon EC2 2012-06-15 High I/O instances provides very high, low latency, 18 July disk I/O performance using SSD-based local 2012 instance storage. For more information, see High I/O Instances (p. 103). 2012-06-01 IAM roles for Amazon EC2 provide: AWS access keys for applications running on Amazon EC2 instances. Automatic rotation of the AWS access keys on the Amazon EC2 instance. Granular permissions for applications running on Amazon EC2 instances that make requests to your AWS services. 11 June 2012
Spot Instance features that make it easier to get started and handle the potential of interruption.
Using Auto Scaling, you can now manage your Spot Instances: Place bids for Amazon EC2 Spot Instances using Auto Scaling launch configurations, and set up a schedule for placing bids for Spot Instances. For more information, see Managing Spot Instances with Auto Scaling (p. 162). Get notifications when instances are launched or terminated. For more information, see Using Auto Scaling to Get Notifications for Spot Instances (p. 174). Use AWS CloudFormation templates to launch Spot Instances in a stack with AWS resources. For more information, see Using CloudFormation Templates to Launch Spot Instances (p. 177).
7 June 2012
Feature
API Version
Description
EC2 instance export and 2012-05-01 Added support for exporting Windows Server timestamps for status instances that you originally imported into EC2. checks for Amazon EC2 Added support for timestamps on instance status and system status to indicate the date and time that a status check failed. EC2 instance export, and timestamps in instance and system status checks for Amazon VPC Cluster Compute Eight Extra Large instances 2012-05-01 Added support for EC2 instance export to Citrix Xen, Microsoft Hyper-V, and VMware vSphere. Added support for timestamps in instance and system status checks.
25 May 2012
2012-04-01 Added support for cc2.8xlarge instances in Amazon 26 April Virtual Private Cloud (Amazon VPC). 2012 19 April 2012 28 March 2012
AWS Marketplace AMIs 2012-04-01 Added support for AWS Marketplace AMIs. New Linux AMI release Added information about the release of Amazon Linux AMI 2012.03. For more information, see Amazon Linux AMIs (p. 73). Added information about the release of new AKI version 1.03 and the release of AKIs for the AWS GovCloud (US) region. For more information, see Enabling Your Own Linux Kernels (p. 80) . Added support for a new instance type and 64-bit information. Added procedures for using the Java-based SSH client to connect to Linux/UNIX instances.
28 March 2012
Medium instances, support for 64-bit on all AMIs, and a Java-based SSH Client Reserved Instance Pricing Tiers
7 March 2012
Added a new section discussing how to take 5 March advantage of the discount pricing that is built into 2012 the Reserved Instance Pricing Tiers. For more information, see Understanding Reserved Instance Pricing Tiers (p. 220). Added new section about elastic network interfaces 21 (ENIs) for EC2 instances in a VPC. For more December information, see Elastic Network Interfaces 2011 (ENI) (p. 471).
Elastic Network Interfaces (ENIs) for EC2 instances in Amazon Virtual Private Cloud New GRU Region and AKIs
Added information about the release of new AKIs 14 for the SA-East-1 Region. This release deprecates December the AKI version 1.01. AKI version 1.02 will continue 2011 to be backward compatible.
New offering types for 2011-11-01 You can choose from a variety of Reserved 01 Amazon EC2 Reserved Instance offerings that address your projected use December Instances of the instance: Heavy Utilization, Medium 2011 Utilization, and Light Utilization. See Reserved Instances (p. 212).
API Version
Description
Release Date
You can view additional details about the status of 16 your instances, including scheduled events planned November by AWS that might have an impact on your 2011 instances. These operational activities include instance reboots required to apply software updates or security patches, or instance retirements required where there are hardware issues. See Monitoring the Status of Your Instances (p. 363). Added support for Cluster Compute Eight Extra Large (cc2.8xlarge) to Amazon EC2. 14 November 2011
Amazon EC2 Cluster Compute Instance Type New PDX Region and AKIs Amazon EC2 Spot Instances in Amazon VPC
Added information about the release of new AKI's 8 for the new US-West 2 Region. November 2011 Added information about the support for Amazon 11 October EC2 Spot Instances in Amazon VPC. With this 2011 update, users will be able to launch Spot Instances in the Amazon Virtual Private Cloud (Amazon VPC). By launching Spot Instances in Amazon VPC, users of Spot Instances can enjoy all of the controls and advanced security options of Amazon VPC. For more information, see Launching Spot Instances in Amazon Virtual Private Cloud (p. 178). Added information about the release of Amazon 26 Linux AMI 2011.09. This update removes the beta September tag from the Amazon Linux AMI, supports the ability 2011 to lock the repositories to a specific version, and provides for notification when updates are available to installed packages including security updates. For more information, see Amazon Linux AMIs (p. 73). The VM Import process for CLI users is simplified 15 with the enhanced functionality of September ec2-import-instance and 2011 ec2-import-volume, which now will perform the upload of the images into Amazon EC2 after creating the import task. In addition, with the introduction of the ec2-resume-import command, users can restart an incomplete upload at the point the task stopped. For more information, see Importing Your Virtual Machine into Amazon EC2 (p. 341) in the Amazon Elastic Compute Cloud User Guide.
API Version
Description
Release Date
VM Import can now import virtual machine image 24 August files in VHD format. The VHD file format is 2011 compatible with the Citrix Xen and Microsoft Hyper-V virtualization platforms. With this release, VM Import now supports RAW, VHD and VMDK (VMware ESX-compatible) image formats. For more information, see Using the Command Line Tools to Import Your Virtual Machine to Amazon EC2 (p. 335) in the Amazon Elastic Compute Cloud User Guide. VM Import now supports Windows Server 2003 (R2). With this release, VM Import supports all versions of Microsoft Windows Server supported by Amazon EC2. 24 August 2011
Added information about the 1.1 version of the 27 June Amazon EC2 VM Import Connector for VMware 2011 vCenter virtual appliance (Connector).This update includes proxy support for Internet access, better error handling, improved task progress bar accuracy, and several bug fixes. For more information, see Importing EC2 Instances (p. 318). Added information about the AKI version change 20 June from 1.01 to 1.02. This version updates the 2011 PVGRUB to address launch failures associated with t1.micro Linux instances. For more information, go to Enabling Your Own Linux Kernels (p. 80). Added information about the Spot Instances 26 May Availability Zone pricing feature. In this release, 2011 we've added new Availability Zone pricing options as part of the information returned when you query for Spot Instance requests and Spot Price history. These additions make it easier to determine the price required to launch a Spot Instance into a particular Availability Zone. For more information, see Spot Instances (p. 135). Added information about AWS Identity and Access 26 April Management (IAM), which enables users to specify 2011 which Amazon EC2 actions a user can use with Amazon EC2 resources in general. For more information, see AWS Identity and Access Management (p. 446). Added information about enabling a Linux AMI to use PVGRUB Amazon Kernel Image (AKI) to run a user-provided kernel. For more information, go to Enabling Your Own Linux Kernels (p. 80). 26 April 2011
API Version
Description
Release Date
Launched within your Amazon Virtual Private Cloud 27 March (Amazon VPC), Dedicated Instances are instances 2011 that are physically isolated at the host hardware level. Dedicated Instances let you take advantage of Amazon VPC and the AWS cloud, with benefits including on-demand elastic provisioning and pay only for what you use, while isolating your Amazon EC2 compute instances at the hardware level. For more information, go to Using EC2 Dedicated Instances Within Your VPC in the Amazon Virtual Private Cloud User Guide. Updates to the AWS Management Console make 27 March it easier for users to view their Reserved Instances 2011 and purchase additional Reserved Instances, including Dedicated Reserved Instances. For more information, see Reserved Instances (p. 212). Amazon EC2 now provides you with several 15 March pre-configured Windows Server 2008 R2 AMIs. 2011 These AMIs are immediately available for use in every Region and in most 64-bit instance types, excluding t1.micro and HPC families. The AMIs will support multiple languages. For more information, see Windows Instance Types (p. 94). Added information about the new Amazon Linux 15 March reference AMI, which replaces the CentOS 2011 reference AMI. Removed information about the CentOS reference AMI, including the section named Correcting Clock Drift for Cluster Instances on CentOS 5.4 AMI. For more information, see Reference AMIs (p. 108). Added information about metadata to reflect changes in the 2011-01-01 release. For more information, see Instance Metadata (p. 374) and Metadata Categories (p. 380). 11 March 2011
Metadata information
Added information about the Amazon EC2 VM 3 March Import Connector for VMware vCenter virtual 2011 appliance (Connector). The Connector is a plug-in for VMware vCenter that integrates with VMware vSphere Client and provides a graphical user interface that you can use to import your VMware virtual machines to Amazon EC2. For more information, see Importing EC2 Instances (p. 318). You can now use the AWS Management Console 23 to force the detachment of an Amazon EBS volume February from an instance. For more information, see 2011 Detaching an Amazon EBS Volume from an Instance (p. 519).
API Version
Description You can now use the AWS Management Console to prevent an instance from being terminated. For more information, see Enabling Termination Protection for an Instance (p. 390).
Correcting Clock Drift for Cluster Instances on CentOS 5.4 AMI Restructured User Guide
Added information about how to correct clock drift 25 January for cluster instances running on Amazon's CentOS 2011 5.4 AMI. Implemented the following updates to the Amazon 14 January EC2 User Guide: 2011 Consolidated all developer guide information into this user guide. Restructured and updated the information about creating AMIs. For more information, see Creating Your Own AMIs (p. 34). Updated the introduction to the user guide. For more information, see What is Amazon EC2? (p. 4)
VM Import
Added information about VM Import, which allows 15 you to import a virtual machine or volume into December Amazon EC2. For more information, see Using the 2010 Command Line Tools to Import Your Virtual Machine to Amazon EC2 (p. 335). Added information about basic monitoring for EC2 12 instances. For more information, see Monitoring December Instances (p. 352). 2010 Amazon EC2 offers cluster GPU instances (cg1.4xlarge) for high-performance computing (HPC) applications. For more information, see Overview (p. 106). Added information about listing, filtering, and tagging resources. For more information, see Listing and Filtering Your Resources (p. 562) and Tagging Your Amazon EC2 Resources (p. 566). 14 November 2010
19 September 2010
Added information about ensuring idempotency 19 when running instances. For more information, see September Ensuring Idempotency (p. 372). 2010 Amazon EC2 offers the t1.micro instance type for 8 certain types of applications. For more information, September see Micro Instances (p. 96). 2010 Amazon EC2 now integrates with AWS Identity and 2 Access Management (IAM). For more information, September see AWS Identity and Access Management (p. 9). 2010
Micro instances
API Version
Description
Release Date
Amazon EC2 offers cluster compute instances for 12 July high-performance computing (HPC) applications. 2010 For more information, see Overview (p. 106). Amazon VPC users can now specify the IP address 12 July to assign an instance launched in a VPC. 2010 Amazon CloudWatch monitoring is now 14 June automatically available for Amazon EBS volumes. 2010 For more information, see Monitoring Volumes with CloudWatch (p. 508). Amazon EC2 now supports a High-Memory Extra 22 Large (m2.xlarge) instance type. For more February information, see Available Instance Types (p. 90). 2010 Amazon EC2 now supports Reserved Instances with Windows. For more information about Reserved Instances, see Reserved Instances (p. 212). 22 February 2010
Amazon VPC IP Address Designation Amazon CloudWatch Monitoring for Amazon EBS Volumes