Terminating VMs

You can terminate a virtual machine (VM) that you no longer need. Terminating a VM releases its corresponding physical resources, therefore the VM cannot be recovered. You can also specify that the VM terminates when shutting it down with the operating system command by enabling the InstanceInitiatedShutDownBehavior attribute.

Terminating a VM Using Cockpit v2

  1. In the VMs dashboard, check the box of the running or stopped VM you want to terminate.

    Multiselection is available.

    The VM is selected.

    If the DisableApiTermination attribute is enabled, you need to disable it before you can terminate the VM. For more information, see Modifying a VM Attribute.

  2. Click IconTerminate Terminate.
    The TERMINATE VMs confirmation dialog box appears.

  3. Click Terminate.
    The state of the selected VM changes to IconPending shutting-down, and then to IconTerminated terminated once the operation is completed.

    Terminated VMs remain visible for approximately 1 hour after deletion.

Deleting VMs Using OSC CLI

The DeleteVms command terminates one or more virtual machines (VMs).
This operation is idempotent, that means that all calls succeed if you terminate a VM more than once.

Request sample
$ osc-cli api DeleteVms --profile "default" \
    --VmIds '["i-12345678"]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • VmIds: One or more IDs of VMs.

The DeleteVms command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • Vms: Information about one or more terminated VMs.

    • CurrentState: The current state of the VM (InService | OutOfService | Unknown).

    • PreviousState: The previous state of the VM (InService | OutOfService | Unknown).

    • VmId: The ID of the VM.

Result sample
{
  "Vms": [
    {
      "VmId": "i-12345678",
      "PreviousState": "running",
      "CurrentState": "shutting-down"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Deleting VMs Using oapi-cli

The DeleteVms command terminates one or more virtual machines (VMs).
This operation is idempotent, that means that all calls succeed if you terminate a VM more than once.

Request sample
$ oapi-cli --profile "default" DeleteVms \
    --VmIds '["i-12345678"]'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • VmIds: One or more IDs of VMs.

The DeleteVms command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • Vms: Information about one or more terminated VMs.

    • CurrentState: The current state of the VM (InService | OutOfService | Unknown).

    • PreviousState: The previous state of the VM (InService | OutOfService | Unknown).

    • VmId: The ID of the VM.

Result sample
{
  "Vms": [
    {
      "VmId": "i-12345678",
      "PreviousState": "running",
      "CurrentState": "shutting-down"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Terminating Instances Using AWS CLI

Before you begin: Install and configure AWS CLI. For more information, see Installing and Configuring AWS CLI.

To terminate one or more instances, use the terminate-instances command following this syntax:

Request sample
$ aws ec2 terminate-instances \
    --profile YOUR_PROFILE \
    --instance-ids i-12345678 \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

The terminate-instances command returns the following elements:

  • TerminatingInstances: Information about one or more terminating instances. This element contains the following information:

    • InstanceId: The ID of the instance.

    • CurrentState: The current state of the instance, with the code and the name of the state.

    • PreviousState: The state of the instance before the action, with the code and the name of the state.

Result sample
{
    "TerminatingInstances": [
        {
            "InstanceId": "i-12345678",
            "CurrentState": {
                "Code": 32,
                "Name": "shutting-down"
            },
            "PreviousState": {
                "Code": 80,
                "Name": "stopped"
            }
        }
    ]
}

The state of the specified instances changes to shutting-down, and then to terminated once the operation is completed.

Terminated instances remain visible for approximately 1 hour after termination.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.