Deploy your Cloudspace via Terraform
Rackspace Spot allows you to create and operate your Cloudspaces via Terraform, using a dedicated Terraform provider.
The Spot Terraform Provider
The Spot Terraform provider is available via the official Terraform registry:
https://registry.terraform.io/providers/rackerlabs/spot/latest
Obtain the Access Token from the Spot User Interface
To get started, log in to your Rackspace Spot account, select the Organization you will operate within, and obtain the Terraform Access Token:
- Navigate to the Terraform menu under API Access on the sidebar
 - Copy the Access Token provided on that page
 - Please note that these Access Tokens provide access to your account and must be stored securely
 - Set the token inside provider configuration as shown in the example below
 
The Access Token doesn't currently include a refresh mechanism.
Using the Terraform Provider
The following example uses the Terraform variable, token, which can be provided from .tfvars  file or environment variable.
x
54
54
terraform   required_providers     spot =       source = "rackerlabs/spot"      variable "rackspace_spot_token"   description = "Rackspace Spot authentication token"  type        = string  sensitive   = trueprovider "spot"   token = var.rackspace_spot_token# Example of cloudspace resource.resource "spot_cloudspace" "example"   cloudspace_name = "name-of-the-cloudspace"  # You can find the available region names in the `regions` data source.  region             = "us-central-dfw-1"  hacontrol_plane    = false  preemption_webhook = "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"  wait_until_ready   = true  kubernetes_version = "1.31.1"  cni                = "calico"# Creates a spot node pool with an autoscaling pool of 3-8 servers of class gp.vs1.large-dfw.resource "spot_spotnodepool" "autoscaling-bid"   cloudspace_name = resource.spot_cloudspace.example.cloudspace_name  # You can find the available server classes in the `serverclasses` data source.  server_class = "gp.vs1.large-dfw"  bid_price    = 0.012  autoscaling =     min_nodes = 3    max_nodes = 8    labels =     "managed-by" = "terraform"  data "spot_kubeconfig" "example"   cloudspace_name = resource.spot_cloudspace.example.nameoutput "kubeconfig"   value = data.spot_kubeconfig.example.rawWas this page helpful?