| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
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 remains idle and you don't connect to it). You can stop instances that use Amazon EBS volumes as their root devices. When you stop an instance, it is shut down, so any data stored in the RAM of the host computer is not preserved. You are not billed for hourly usage or data transfer, but you are 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 these transitions happen multiple times within a single hour.
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 more information about pricing for Amazon EC2, see Amazon EC2 Pricing.
Topics
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 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 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 Balancing 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 in the Amazon Elastic Compute Cloud Microsoft Windows Guide.
The next sections provide more detail about some of the areas covered in the preceding list.
Network
When you stop an instance, we release its public and private IP addresses; we assign new IP addresses when you restart the instance. The exception is that instances launched into a VPC keep their private IP address when stopped and restarted. Therefore, it is possible to have a 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 in the Amazon Elastic Compute Cloud 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 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 are charged for the Elastic IP address. For more information about the charges for Elastic IP addresses, see 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.
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.
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).
You can't change anything about the instance's block device mapping
except the DeleteOnTermination flag for an attached volume. For more information,
see ec2-modify-instance-attribute
in the Amazon Elastic Compute Cloud Command Line Reference
or ModifyInstanceAttribute
in the Amazon Elastic Compute Cloud API Reference.
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, by default, any volumes that you attach to a running
instance persist even after the instance terminates. This behavior is controlled by the volume's
DeleteOnTermination flag.
You can see the value for the DeleteOnTermination flag the volumes attached to an instance
by looking at the instance's block device mapping. For more information, see Viewing the EBS Volumes in an Instance Block Device Mapping.
You can change the value of a volume's DeleteOnTermination flag while the instance is running.
For an example of how to specify this flag when launching an instance,
see Changing the Root Device Volume to Persist.
For information about changing this flag for a running instance, see
ec2-modify-instance-attribute
in the Amazon Elastic Compute Cloud Command Line Reference
or ModifyInstanceAttribute
in the Amazon Elastic Compute Cloud API Reference.
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.
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 (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). For more information, see Enabling Termination Protection for an
Instance.