Skip to content
  • There are no suggestions because the search field is empty.

Provision virtual machines with the Compute Terraform provider

Install, configure, and define compute-cloud VMs as code with Terraform or OpenTofu

 

This product is in closed beta testing. If you need an access, please contact your sales manager or fill in the form here:
https://www.impossiblecloud.com/ai-services 

Overview

The Compute Terraform provider lets you provision compute-cloud virtual machines as code. It works with both Terraform and OpenTofu. The provider is published to the self-hosted Terralist registry, so you need registry access configured (authority impossiblecloud, provider compute).

Install the provider

Add the provider to your configuration, then run terraform init (or tofu init) to pull it from the registry.

terraform {
  required_providers {
    compute = {
      source  = "terralist.impossiblecloud.network/impossiblecloud/compute"
      version = "0.0.2"
    }
  }
}

Configure the provider

provider "compute" {
  endpoint = "https://<your-compute-cloud-endpoint>"
}
Argument Type Required Description
endpoint String Optional Base URL of the compute-cloud API. Falls back to the COMPUTE_CLOUD_ENDPOINT environment variable when unset.

Define a virtual machine

The compute_virtual_machine resource manages a single VirtualMachine. You set the name and a template, and the provider creates the VM and tracks its runtime state.

resource "compute_virtual_machine" "example" {
  name = "myvm"

  template = {
    name = "ubuntu"
    parameters = {
      INSTANCETYPE = "g1.8xlarge"
      MAC          = "02:00:00:de:ad:01" # required — must be unique per VM
    }
  }
}

The public IP is populated once the LoadBalancer is provisioned:

output "vm_ip" {
  value = compute_virtual_machine.example.network.ip
}

Required arguments

Name Type Description
name String Name of the VirtualMachine.
template Attributes VirtualMachineTemplate to instantiate the VM from. See the template block below.

Optional arguments

Name Type Description
timeouts Block See the timeouts block below.
wait_for Attributes Block until the VM's runtime output matches all fields entries. Applied during Create only. See the wait_for block below.

Read-only attributes

Name Type Description
id String Identifier of the VirtualMachine. Equal to name.
network Attributes Public network endpoint, exposed via a LoadBalancer Service. Null when no Service is configured. See the network block below.
state Attributes Runtime status of the VirtualMachine and its associated LoadBalancer Service. See the state block below.

Nested attributes

template

Required

Name Type Description
name String Name of the VirtualMachineTemplate.

Optional

Name Type Description
parameters Map of String Template parameter values. The NAME parameter is set automatically by the server.

timeouts

Optional

Name Type Description
create String A duration string consisting of numbers and unit suffixes, such as 30s or 2h45m. Valid units: s, m, h. See the Go duration format.
update String A duration string consisting of numbers and unit suffixes, such as 30s or 2h45m. Valid units: s, m, h. See the Go duration format.

wait_for

Required

Name Type Description
fields Map of String Map of dot-separated VM output paths to expected string values. Supported keys: state.vm, state.service, network.ip.

network

Read-only

Name Type Description
ip String Public IP address. Null until the LoadBalancer is provisioned.
ports List of Number Exposed TCP ports.

state

Read-only

Name Type Description
service String LoadBalancer Service status (for example Running or Pending). Null when no Service is exposed.
vm String VirtualMachine status (for example Running, Stopped, or Starting).