StartInstances, StopInstances, RebootInstances
Objective
Section titled “Objective”Three actions that change whether an instance is running. They differ in what survives, what is charged, and whether the instance may move to another machine.
Permissions
Section titled “Permissions”| Action | Resource scope | ARN shape |
|---|---|---|
ec2:StartInstances | Resource-scoped | instance/<id> |
ec2:StopInstances | Resource-scoped | instance/<id> |
ec2:RebootInstances | Resource-scoped | instance/<id> |
Instructions
Section titled “Instructions”StopInstances
Section titled “StopInstances”Shuts the operating system down and releases CPU and memory. The root volume is kept.
| Parameter | Type | Required | Notes |
|---|---|---|---|
InstanceId.N | list | Yes | |
Force | boolean | No | Stop without a clean shutdown |
DryRun | boolean | No |
Force skips the guest shutdown. It is the equivalent of removing power, and it
risks filesystem corruption in the same way. Use it when a guest has stopped
responding, not as a default.
Response: instancesSet, each with instanceId, previousState and
currentState.
<StopInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>b1e2c3d4-5678-90ab-cdef-1234567890ab</requestId> <instancesSet> <item> <instanceId>i-0a1b2c3d4e5f60718</instanceId> <currentState><code>64</code><name>stopping</name></currentState> <previousState><code>16</code><name>running</name></previousState> </item> </instancesSet></StopInstancesResponse>Billing: rating counts a running instance, by its shape, per hour — so
the charge ends when the instance leaves running.
Its root disk is not billed separately, because storage is not rated at all today. It does still occupy the pool, so a stopped instance costs you nothing and costs the platform capacity. See Billing user guide.
The public address is not retained. A stopped instance that is started again may receive a different address.
Stopping an already-stopped instance succeeds and reports its current state.
StartInstances
Section titled “StartInstances”Starts a stopped instance.
| Parameter | Type | Required |
|---|---|---|
InstanceId.N | list | Yes |
DryRun | boolean | No |
The instance returns to pending, then running. It may be placed on a
different physical machine, which is why a start can fail for capacity when
the original launch did not.
Errors
| Code | Status | Cause |
|---|---|---|
IncorrectInstanceState | 400 | The instance is not stopped |
InsufficientInstanceCapacity | 500 | No capacity for that type now |
InvalidInstanceID.NotFound | 400 | No such instance |
InsufficientInstanceCapacity on a start is worth calling out: an instance you
stopped is not capacity held for you. Stopping releases it, and starting
competes for it again.
RebootInstances
Section titled “RebootInstances”Restarts the guest operating system in place.
| Parameter | Type | Required |
|---|---|---|
InstanceId.N | list | Yes |
DryRun | boolean | No |
The instance does not leave running, does not change machine, keeps its
address, and continues to be charged. The response carries no instance state,
only a request id and return.
A reboot is not a stop-then-start, and cannot be used to move an instance to a different machine or to change its address.
Which to use
Section titled “Which to use”| You want to | Use |
|---|---|
| Restart the OS | RebootInstances |
| Stop paying for compute, keep the disk | StopInstances |
| Stop paying entirely, lose the disk | TerminateInstances |
| Move to another machine | Stop, then start |
Go further
Section titled “Go further”- TerminateInstances
- Instance lifecycle