Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

TerminateInstances

Shuts down one or more instances. This operation is idempotent; if you terminate an instance more than once, each call succeeds.

If you specify multiple instances and the request fails (for example, because of a single incorrect instance ID), none of the instances are terminated.

Terminated instances remain visible after termination (for approximately one hour).

By default, Amazon EC2 deletes all EBS volumes that were attached when the instance launched. Volumes attached after instance launch continue running.

You can stop, start, and terminate EBS-backed instances. You can only terminate instance store-backed instances. What happens to an instance differs if you stop it or terminate it. For example, when you stop an instance, the root device and any other devices attached to the instance persist. When you terminate an instance, any attached EBS volumes with the DeleteOnTermination block device mapping parameter set to true are automatically deleted. For more information about the differences between stopping and terminating instances, see Instance Lifecycle in the Amazon Elastic Compute Cloud User Guide.

For more information about troubleshooting, see Troubleshooting Terminating Your Instance in the Amazon Elastic Compute Cloud User Guide.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.

DryRun

Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Type: Boolean

Required: No

InstanceId.N

One or more instance IDs.

Constraints: Up to 1000 instance IDs. We recommend breaking up this request into smaller batches.

Type: array of Strings

Required: Yes

Response Elements

The following elements are returned by the service.

instancesSet

Information about one or more terminated instances.

Type: array of InstanceStateChange objects

requestId

The ID of the request.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors.

Example

Example

This example terminates the specified instance.

Sample Request

Copy
https://ec2.amazonaws.com/?Action=TerminateInstances &InstanceId.1=i-1234567890abcdef0 &AUTHPARAMS

Sample Response

Copy
<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <instancesSet> <item> <instanceId>i-1234567890abcdef0</instanceId> <currentState> <code>32</code> <name>shutting-down</name> </currentState> <previousState> <code>16</code> <name>running</name> </previousState> </item> </instancesSet> </TerminateInstancesResponse>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: