
Getty Images/iStockphoto
Public cloud vendors continue to roll out new pricing models and lower-cost services. Enterprises need to fully understand what they sign up for before they apply these models to production workloads.
Google Cloud users who want to save money should consider a Spot VM and evaluate its common use cases. If it is the right choice for you, follow these step-by-step instructions to create a Spot VM using Google Cloud Console, the CLI and Terraform.
A Spot VM -- formerly known as a preemptible VM -- is a virtual machine that you can create and run at significantly reduced costs. The caveat for Spot VMs is that Google Cloud infrastructure can preempt your Spot VMs at any time, terminating the VM and causing you to lose your data within it.
The ideal use case for Spot VMs is workloads that can tolerate disruption, such as testing environments. It is not a good option for any workload that requires constant availability, such as business-critical applications, or persistent data storage, such as big data and analytics.
Working with Spot VM discounts can be tricky if you're unfamiliar with their discount model. Like Spot VMs that AWS and Azure offer customers, Google's Spot VMs provide as much as 80% off the cost of a regular VM. The exact discount varies depending on theregion and availability of resources, so expect fluctuations based on demand.
Google uses a complex algorithm to determine Spot VM pricing based on supply and demand, which makes it impossible to game this system or determine Spot VM pricing and availability patterns. The current market price for unused resources in your selected region is the basis for your Spot VM discount. Pricing can change at any time.
There are nocloud FinOps secrets to tell here. You set the maximum price for what you're willing to pay for a Spot VM. If the market price is below the maximum price you set, you can create your Spot VM, and Google charges you the current market price. When the market price rises above the maximum price you set, then Google can preempt and terminate your Spot VM.
To set up a Spot VM in the Google Cloud Console, follow these steps:
Step 1. Open the Google Cloud Console and select the project in which you want to create a Spot VM.
Step 2. Locate the Compute Engine page in the left navigation menu.
Step 3. ClickVM instances to open the VM instances page.
Step 4. ClickCreate Instance to begin creating a new VM.
Step 5. Under Machine configuration, select the Machine family, Series and Machine type.
Step 6. Scroll down to the Advanced options section and expand it.
Step 7. Scroll to the Management section and select Spot as the VM provisioning model.
Step 8. Configure any additional options, such as host maintenance and automatic restart.
Step 9. ClickCreate to create the Spot VM.
To create a Spot VM using the Google Cloud CLI, follow these steps:
Step 1. Open a command prompt or terminal window andinstall the Cloud SDK if you haven't already done so.
Step 2. Authenticate the gcloud tool with your GCP account by running the following command and then following the prompts:
gcloud auth login
Step 3. Set the default project for the gcloud tool by running the following command:
gcloud config set project PROJECT_ID
Step 4. Replace thePROJECT_ID with the ID of the project where you want to create the Spot VM.
Step 5. Create a new Spot VM instance by running the following command:
gcloud compute instances create NAME --preemptible --image IMAGE_NAME
Step 6. ReplaceNAME with the name you want to give to your Spot VM instance and IMAGE_NAME with the name of the image you want to use.
To create a Spot VM usingTerraform, follow these steps:
Step 1. Install Terraform on your local machine by following the instructions in theofficial documentation.
Step 2. Set up a new Terraform configuration file in a new directory and add the required provider information for GCP. Here's a sample configuration file:
provider "google" { project = "<project_id>" region = "<region>" zone = "<zone>"}resource "google_compute_instance" "spot_instance" { name = "my-spot-vm" machine_type = "n1-standard-1" boot_disk { initialize_params { image = "debian-cloud/debian-10" } } network_interface { network = "default" access_config { // Ephemeral IP } } scheduling { preemptible = true }}Replace the following placeholders:
Step 3. Define a new compute instance in your Terraform configuration file by adding the following code:
resource "google_compute_instance" "spot_instance" { name = "my-spot-vm" machine_type = "n1-standard-1" boot_disk { initialize_params { image = "debian-cloud/debian-10" } } network_interface { network = "default" access_config { // Ephemeral IP } } scheduling { preemptible = true }}Step 4. Runterraform init in your new directory to initialize the Terraform working directory and download the required provider plugins.
Step 5. Runterraform plan to see a preview of the changes Terraform will make to your resources.
Step 6. Runterraform apply to create the Spot VM instance.
Decentralized data centers enhance scalability, reduce latency and improve data compliance, offering a strategic shift for ...
Data center admins should adopt a composable architecture to improve resource utilization, reduce costs and enhance AI workload ...
There are regulated requirements to maintain data center equipment and functionality. ISO 14644 cleanroom standards lay out ...
The director of engineering for a Fortune 20 automotive company spoke on the latest cloud-native tools for platform engineering, ...
CIOs face mounting talent challenges as tech skills rapidly become obsolete and companies poach top performers. Five proven ...
Presentations at KubeCon 2025 detailed efforts since last year's conference to enhance support for AI on Kubernetes platforms and...
Compare Datadog vs. New Relic capabilities including alerts, log management, incident management and more. Learn which tool is ...
Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates ...
There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service ...
Take advantage of Horizon 7 with VMC on AWS for a better hybrid cloud user experience, new use cases, and several different ...
Hock Tan talked only for several minutes during the keynote at VMware Explore 2025, but in that time, he laid the groundwork for ...
The first major revision of the VMware platform under Broadcom's ownership is now available to all VMware Cloud Foundation and ...
