Official Terraform provider for managing infrastructure on CubePath Cloud.
export CUBE_API_TOKEN="your-api-token-here"make build
make installSee the examples directory for complete usage examples.
terraform {
required_providers {
cubepath = {
source = "cubepath/cubepath"
version = "~> 1.0"
}
}
}
provider "cubepath" {
# API token can be set via CUBE_API_TOKEN environment variable
# api_token = var.cubepath_api_token
}
# Option 1: Create an SSH key with Terraform
resource "cubepath_ssh_key" "main" {
name = "my-key"
public_key = file("~/.ssh/id_rsa.pub")
}
# Option 2: Look up an existing SSH key by name (no resource needed)
# data "cubepath_ssh_key" "existing" { name = "existing-key-name" }
# Then in VPS: ssh_key_ids = [tonumber(data.cubepath_ssh_key.existing.id)]
# Create a project
resource "cubepath_project" "app" {
name = "my-app"
description = "My application infrastructure"
}
# Create a private network
resource "cubepath_network" "private" {
name = "app-network"
project_id = cubepath_project.app.id
location = "us-mia-1"
ip_range = "10.0.1.0"
prefix = 24
}
# Create a VPS with private network
resource "cubepath_vps" "web" {
name = "web-server"
project_id = cubepath_project.app.id
location = "us-mia-1"
plan_name = "gp.pro"
template_name = "debian-12"
network_id = cubepath_network.private.id
ssh_key_ids = [tonumber(cubepath_ssh_key.main.id)]
}cubepath_ssh_key- Manage SSH keyscubepath_project- Manage projectscubepath_network- Manage private networkscubepath_vps- Manage VPS instancescubepath_baremetal- Manage baremetal serverscubepath_firewall_group- Manage firewall groupscubepath_floating_ip- Manage floating IPscubepath_dns_zone- Manage DNS zonescubepath_dns_record- Manage DNS recordscubepath_load_balancer- Manage load balancerscubepath_lb_listener- Manage load balancer listenerscubepath_cdn_zone- Manage CDN zonescubepath_cdn_origin- Manage CDN originscubepath_cdn_rule- Manage CDN cache rulescubepath_cdn_waf_rule- Manage CDN WAF rulescubepath_kubernetes_cluster- Manage Kubernetes clusterscubepath_kubernetes_node_pool- Manage Kubernetes node poolscubepath_kubernetes_addon- Manage Kubernetes addonscubepath_availability_group- Manage availability groups for high availability
cubepath_locations- List available locationscubepath_vps_plans- List available VPS plans and pricingcubepath_vps_templates- List available OS templatescubepath_ssh_key- Look up an existing SSH keycubepath_firewall_groups- List firewall groupscubepath_dns_zones- List DNS zonescubepath_lb_plans- List load balancer planscubepath_cdn_plans- List CDN planscubepath_kubernetes_versions- List Kubernetes versionscubepath_kubernetes_plans- List Kubernetes node planscubepath_kubernetes_addons- List Kubernetes addonscubepath_kubeconfig- Get cluster kubeconfigcubepath_availability_groups- List availability groups for a project
See the examples directory for complete usage examples:
complete-vps-deployment.tf- Basic VPS deploymentvps-with-password.tf- VPS with password authenticationcomplete-infrastructure.tf- Full infrastructure with networks, data sources, and multiple VPS
## Useful Commands
### Testing your configuration
```bash
# Validate configuration
terraform validate
# Format configuration files
terraform fmt
# Preview changes
terraform plan
# Apply changes
terraform apply
# Destroy resources
terraform destroy
# Import a VPS (get ID from dashboard or API)
terraform import cubepath_vps.existing <vps-id>
# Import a project
terraform import cubepath_project.existing <project-id># Enable debug logging
export TF_LOG=DEBUG
terraform apply
# Trace-level logging (verbose)
export TF_LOG=TRACE
terraform applyMake sure you've set the API token:
export CUBE_API_TOKEN="your-token"
echo $CUBE_API_TOKEN # Verify it's setReinstall the provider:
make installIncrease the timeout in your resource configuration:
resource "cubepath_vps" "web" {
# ... other config ...
timeouts {
create = "25m" # Increase from default
}
}If you get this error, you have 3 options:
Option 1: Use the existing key (recommended)
resource "cubepath_vps" "web" {
# ... other config ...
ssh_key_ids = [12] # Just reference by name
}Option 2: Import the existing key
terraform import cubepath_ssh_key.main <key-id>Option 3: Change the name
resource "cubepath_ssh_key" "main" {
name = "my-key-2" # Use a different name
# ...
}If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install. This will build the provider and put the provider binary in the $GOPATH/bin directory.
In order to run the full suite of Acceptance tests, run make testacc.
Note: Acceptance tests create real resources, and often cost money to run.
make testaccApache 2.0