> For the complete documentation index, see [llms.txt](https://docs.acecloud.ai/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acecloud.ai/knowledge-base/cli/compute/spot.md).

# Spot Instances

Spot instances run on spare AceCloud capacity at a lower hourly price than on-demand instances. In exchange, they can be shut off when the market price rises above a limit you set. The `ace spot` command provides full lifecycle management: creation, power control, price inspection, and deletion.

Spot instances use the standard cloud instance API with `billing_type` set to `spot`.

**Introduced in:** CLI v1.5.0

***

## Table of Contents

* [Before You Start](#before-you-start)
* [View Spot Prices](#view-spot-prices)
* [List Available Images](#list-available-images)
* [Create a Spot Instance](#create-a-spot-instance)
  * [Required Flags](#required-flags)
  * [Optional Flags](#optional-flags)
  * [Boot From a Snapshot](#boot-from-a-snapshot)
  * [Pass a Cloud-Init Script](#pass-a-cloud-init-script)
* [List Spot Instances](#list-spot-instances)
* [Get Spot Instance Details](#get-spot-instance-details)
* [Update the Termination Price](#update-the-termination-price)
* [Power Management](#power-management)
* [Delete Spot Instances](#delete-spot-instances)
* [Understanding the Termination Price](#understanding-the-termination-price)
* [Command Reference](#command-reference)
* [Example Workflow](#example-workflow)

***

## Before You Start

Two things about spot instances differ from on-demand instances and are worth knowing up front:

* **They can be shut off.** If you set a termination price and the market price rises above it, the instance is shut off. Do not run anything on a spot instance that cannot tolerate being interrupted.
* **GPU spot requests are asynchronous.** A successful `ace spot create` for a GPU flavor means the request was *accepted*, not that the instance is running. Check the outcome with `ace spot list` or `ace spot get <instance-id>`.

***

## View Spot Prices

Spot prices move with demand, so check the current price before you create anything. You also need the current price to choose a sensible termination price.

```bash
ace spot prices
```

**Output columns:** Flavor, Resource Type, vCPU, RAM, Type, Currency, Spot Price (per hour).

```
FLAVOR                         RESOURCE TYPE  VCPU   RAM      TYPE        CURRENCY   SPOT PRICE (per hour)
S4a.medium                     compute        1      4 GB     standard    USD        0.0128
S4a.large                      compute        2      8 GB     standard    USD        0.0288
S4a.4xlarge                    compute        16     64 GB    standard    USD        0.2177
C4a.medium                     compute        1      2 GB     cpu         USD        0.0124
M3a.8xlarge                    compute        32     256 GB   memory      USD        0.5776
```

The full list is long, so filter it:

| Flag         | Description                                                                              |
| ------------ | ---------------------------------------------------------------------------------------- |
| `--flavor`   | Show the price for a single flavor name or UUID                                          |
| `--gpu`      | GPU flavors only                                                                         |
| `--linux`    | Linux non-GPU flavors only                                                               |
| `--windows`  | Windows non-GPU flavors only                                                             |
| `--os-type`  | Filter by OS type. Cannot be combined with `--linux`, `--windows` or `--gpu`             |
| `--count`    | Number of instances to price (default `1`)                                               |
| `--currency` | Currency code                                                                            |
| `--usd`      | Show prices in USD                                                                       |
| `--inr`      | Show prices in INR                                                                       |
| `--cpu`      | Non-GPU flavors only (legacy; cannot be combined with `--gpu`, `--linux` or `--windows`) |

```bash
# Price one flavor
ace spot prices --flavor S4a.large

# GPU flavors, in INR
ace spot prices --gpu --inr

# Cost of running four instances of a flavor
ace spot prices --flavor C4a.medium --count 4
```

> **Note on currency:** prices are returned in your account's billing currency unless you override it. If `ace auth me` reports one currency and `ace spot prices` shows another, pin it explicitly with `--usd` or `--inr` so you know what you are comparing against.

***

## List Available Images

Not every image can be used for a spot instance. List the ones that can:

```bash
ace spot images
```

**Aliases:** `image`, `image-list`

**Output columns:** ID, Name, Status, Size, Visibility.

```
ID                                     NAME                                STATUS           SIZE VISIBILITY
e081161e-2371-47bb-b40e-d1d8991a55a4   Ubuntu-26.04-LTS                    active        20.0 GB public
ad6b342b-7c30-472b-9350-a847618ef72b   Ubuntu-22.04-LTS                    active        20.0 GB public
849f6c58-20e0-44c0-8b67-a3362723ee21   Ubuntu-22.04-LTS-NVIDIA-580-Base    active        15.0 GB public
d496946b-7149-4680-a4c9-48904b7f7403   Windows-server-2022                 active        50.0 GB public
63f295b3-c11b-45c9-a148-6a1a031bed87   Debian-13                           active         5.0 GB public
```

| Flag         | Description                           |
| ------------ | ------------------------------------- |
| `--os`       | Filter by OS, e.g. `ubuntu`, `centos` |
| `--gpu`      | GPU images only                       |
| `--category` | Filter by category                    |

```bash
ace spot images --os ubuntu
ace spot images --gpu
```

Use either the name or the ID from this list with `ace spot create --image`.

***

## Create a Spot Instance

```bash
ace spot create \
  --name my-spot-vm \
  --flavor C4i.medium \
  --image Ubuntu-22.04-LTS \
  --network <network-id> \
  --security-group <sg-id> \
  --termination-price 1.81
```

The instance is created at the current server price for the selected flavor.

### Required Flags

| Flag               | Description                      |
| ------------------ | -------------------------------- |
| `--name`           | Instance name                    |
| `--flavor`         | Flavor name or UUID              |
| `--network`        | Network UUID (repeatable)        |
| `--security-group` | Security group UUID (repeatable) |

You must also supply a boot source: either `--image` or `--snapshot`.

### Optional Flags

| Flag                  | Default                        | Description                                                                              |
| --------------------- | ------------------------------ | ---------------------------------------------------------------------------------------- |
| `--termination-price` |                                | Maximum spot price you accept. The instance is shut off when the market price exceeds it |
| `--image`             |                                | Image name or UUID                                                                       |
| `--snapshot`          |                                | Volume snapshot name or UUID                                                             |
| `--source-type`       | `image`                        | Boot source type: `image` or `snapshot`. Inferred from the boot flag you use             |
| `--key`               |                                | SSH key pair name                                                                        |
| `--description`       |                                | Instance description                                                                     |
| `--count`             | `1`                            | Number of instances to create                                                            |
| `--boot-size`         | `20`                           | Boot volume size in GB                                                                   |
| `--volume-type`       | `NVMe based High IOPS Storage` | Boot volume type                                                                         |
| `--availability-zone` | `nova`                         | Availability zone                                                                        |
| `--script`            |                                | Inline plaintext cloud-init or user-data script                                          |
| `--script-file`       |                                | Path to a plaintext cloud-init or user-data script                                       |
| `--config-drive`      | `false`                        | Enable config drive                                                                      |

> `--network` and `--security-group` take a **network/VPC UUID** and a **security group UUID**, not names. Get them from `ace vpc list` and `ace security-group list`.

### Boot From a Snapshot

Instead of an image, boot from an existing volume snapshot. Set `--boot-size` to at least the snapshot's size.

```bash
ace spot create \
  --name my-spot-vm \
  --flavor C4i.medium \
  --snapshot <snapshot-id-or-name> \
  --network <network-id> \
  --security-group <sg-id> \
  --termination-price 1.81 \
  --boot-size 20
```

`--source-type` is inferred from the boot flag, so you do not normally need to set it.

### Pass a Cloud-Init Script

Run configuration at first boot, either inline or from a file:

```bash
# Inline
ace spot create \
  --name my-spot-vm \
  --flavor C4i.medium \
  --image Ubuntu-22.04-LTS \
  --network <network-id> \
  --security-group <sg-id> \
  --termination-price 1.81 \
  --script '#!/bin/bash
echo hello'

# From a file
ace spot create \
  --name my-spot-vm \
  --flavor C4i.medium \
  --image Ubuntu-22.04-LTS \
  --network <network-id> \
  --security-group <sg-id> \
  --script-file ./bootstrap.sh
```

The script must be **plaintext** — the CLI handles any encoding the API requires.

***

## List Spot Instances

```bash
ace spot list
```

**Aliases:** `ls`

When the project has no spot instances, the command prints `No spot instances found.`

The listing shows each instance's launch price (`spot_flavor_launch_price`) and its configured maximum price (`spot_flavor_termination_price`), so you can see what you are paying against what you agreed to.

```bash
ace spot list -o json
```

***

## Get Spot Instance Details

```bash
ace spot get <instance-id>
```

**Aliases:** `show`, `describe`

Use this to confirm the eventual status of an asynchronous GPU spot request, and to read the instance's launch and termination prices.

***

## Update the Termination Price

Change the maximum price you accept on a running spot instance:

```bash
ace spot update <instance-id> --termination-price 2.25
```

Pass `0` to disable price-based shutoff entirely:

```bash
ace spot update <instance-id> --termination-price 0
```

***

## Power Management

```bash
ace spot start <instance-id>     # alias: resume
ace spot stop <instance-id>
ace spot pause <instance-id>
ace spot reboot <instance-id>
ace spot reboot <instance-id> --hard
```

`--hard` performs a hard reboot; without it the reboot is soft.

***

## Delete Spot Instances

Accepts one or more instance IDs:

```bash
ace spot delete <instance-id>
ace spot delete <instance-id-1> <instance-id-2>
```

**Aliases:** `rm`

Deletion prompts for confirmation. In scripts and CI, where there is no TTY, pass `--yes`:

```bash
ace spot delete <instance-id> --yes
```

***

## Understanding the Termination Price

`--termination-price` is the **maximum hourly spot price you are willing to pay**.

* When set, the instance is shut off if the market price rises above it.
* The value must be **greater than the current spot price** for the flavor. Check `ace spot prices` first.
* When omitted, no price-based shutoff is configured — the instance is not shut off on price.
* Set it to `0` with `ace spot update` to remove an existing limit.

A higher limit means the instance survives larger price swings but can cost more per hour. A limit close to the current price is cheaper to cap but far more likely to trigger a shutoff.

***

## Command Reference

| Command                        | Description                          |
| ------------------------------ | ------------------------------------ |
| `ace spot list`                | List spot instances                  |
| `ace spot get <id>`            | Get spot instance details            |
| `ace spot create`              | Create a spot instance               |
| `ace spot update <id>`         | Update the termination price         |
| `ace spot delete <id> [id...]` | Delete spot instance(s)              |
| `ace spot start <id>`          | Start a spot instance                |
| `ace spot stop <id>`           | Stop a spot instance                 |
| `ace spot pause <id>`          | Pause a spot instance                |
| `ace spot reboot <id>`         | Reboot a spot instance               |
| `ace spot prices`              | List current spot prices             |
| `ace spot images`              | List images usable for spot creation |

***

## Example Workflow

```bash
# Step 1: Check the current price for the flavor you want
ace spot prices --flavor S4a.large

# Step 2: Pick an image
ace spot images --os ubuntu

# Step 3: Collect the network and security group IDs
ace vpc list
ace security-group list

# Step 4: Create the instance with a limit above the current price
ace spot create \
  --name my-spot-vm \
  --flavor S4a.large \
  --image Ubuntu-22.04-LTS \
  --network <network-id> \
  --security-group <sg-id> \
  --key my-keypair \
  --termination-price 0.05

# Step 5: Confirm it came up (GPU requests are asynchronous)
ace spot list
ace spot get <instance-id>

# Step 6: Raise the limit if prices are volatile
ace spot update <instance-id> --termination-price 0.08

# Step 7: Clean up when finished
ace spot delete <instance-id> --yes
```
