AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Container for the parameters to the StopInstances operation. Stops an Amazon EBS-backed instance. For more information, see Stop and start Amazon EC2 instances in the Amazon EC2 User Guide.
When you stop an instance, we shut it down. You can restart your instance at any time.
You can use the Stop operation together with the Hibernate parameter to hibernate an instance if the instance is enabled for hibernation and meets the hibernation prerequisites. Stopping an instance doesn't preserve data stored in RAM, while hibernation does. If hibernation fails, a normal shutdown occurs. For more information, see Hibernate your Amazon EC2 instance in the Amazon EC2 User Guide.
If your instance appears stuck in the stopping
state, there might be an issue
with the underlying host computer. You can use the Stop operation together with the
Force parameter to force stop your instance. For more information, see Troubleshoot
Amazon EC2 instance stop issues in the Amazon EC2 User Guide.
Stopping and hibernating an instance differs from rebooting or terminating it. For example, a stopped or hibernated instance retains its root volume and any data volumes, unlike terminated instances where these volumes are automatically deleted. For more information about the differences between stopping, hibernating, rebooting, and terminating instances, see Amazon EC2 instance state changes in the Amazon EC2 User Guide.
We don't charge for instance usage or data transfer fees when an instance is stopped. However, the root volume and any data volumes remain and continue to persist your data, and you're charged for volume usage. Every time you start your instance, Amazon EC2 charges a one-minute minimum for instance usage, followed by per-second billing.
You can't stop or hibernate instance store-backed instances.
Namespace: Amazon.EC2.Model
Assembly: AWSSDK.EC2.dll
Version: 3.x.y.z
public class StopInstancesRequest : AmazonEC2Request IAmazonWebServiceRequest
The StopInstancesRequest type exposes the following members
Name | Description | |
---|---|---|
![]() |
StopInstancesRequest() |
Empty constructor used to set properties independently even when a simple constructor is available |
![]() |
StopInstancesRequest(List<String>) |
Instantiates StopInstancesRequest with the parameterized properties |
Name | Type | Description | |
---|---|---|---|
![]() |
Force | System.Boolean |
Gets and sets the property Force. Forces the instance to stop. The instance will first attempt a graceful shutdown, which includes flushing file system caches and metadata. If the graceful shutdown fails to complete within the timeout period, the instance shuts down forcibly without flushing the file system caches and metadata. After using this option, you must perform file system check and repair procedures. This option is not recommended for Windows instances. For more information, see Troubleshoot Amazon EC2 instance stop issues in the Amazon EC2 User Guide.
Default: |
![]() |
Hibernate | System.Boolean |
Gets and sets the property Hibernate. Hibernates the instance if the instance was enabled for hibernation at launch. If the instance cannot hibernate successfully, a normal shutdown occurs. For more information, see Hibernate your instance in the Amazon EC2 User Guide.
Default: |
![]() |
InstanceIds | System.Collections.Generic.List<System.String> |
Gets and sets the property InstanceIds. The IDs of the instances. |
This example stops the specified EC2 instance.
var client = new AmazonEC2Client(); var response = client.StopInstances(new StopInstancesRequest { InstanceIds = new List<string> { "i-1234567890abcdef0" } }); List<InstanceStateChange> stoppingInstances = response.StoppingInstances;
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.5 and newer, 3.5