With the Gcore Terraform provider v0, teams define Cloud resources — Virtual Machines, Kubernetes clusters, networks, and more — in configuration files, then apply them consistently across environments without clicking through the Portal. The following resources are supported: Virtual Machines, Bare Metal servers, Kubernetes clusters, Load Balancers, networks, volumes, snapshots, server groups, and reserved IP addresses. Provider installation and authentication are covered in the Terraform overview. The v2 provider with expanded resource support is available in Terraform v2. To migrate an existing v0 configuration, follow the migration guide.Documentation Index
Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Workflow
Add resource configuration tomain.tf, then run:
yes when prompted. The getting started guide covers the full workflow.
Networking
The following resources configure private networks, subnets, and IP addresses.Create a network and subnetwork
The following configuration creates a network and an optional subnetwork within it.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the network.
- Specify “name”.
- (optional) Add
create_router = "false"to remove the external router from the network. Otherwise, the external router will be added by default. - (optional) Add
type = "vlan". Otherwise, a “vxlan” network will be created by default. - (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- To skip the subnetwork, stop here. To create a subnetwork, add the code below and customize the highlighted values:
- Configure the subnetwork.
- Specify the “name” of the subnetwork.
- Specify the “cidr”.
- Select the IP address from the ranges: 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, and 192.168.0.0–192.168.255.255.
- Select the subnet mask from 16 to 24.
- Specify the “network_id” of the network in which the subnet will be created.
- (optional) Add
connect_to_network_router = "true"to make the subnetwork accessible through an external router. To disable this, addconnect_to_network_router = "false". The default value is “true”. - (optional) Add the “gateway_ip” of an external router, if any.
- (optional) Specify “dns_nameservers”.
- (optional) Add “host_routes”.
- Specify the “destination”, the CIDR of the target subnetwork.
- Specify the “nexthop”, the IPv4 address to forward traffic to if its destination IP matches the “destination” CIDR.
- (optional) Add “enable_dhcp = false” to disable DHCP. Otherwise, DHCP is enabled by default. For IPv6 networks, DHCP can be enabled or disabled at creation time — changing this setting later requires recreating the subnetwork.
- (optional) Specify the “region_id” and “region_name”.
- (optional) Specify the “project_id” and “project_name”.
Reserve an IP address
The following configuration reserves a fixed IP address for use with instances or load balancers.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the reserved IP address.
- Specify the “type”: “subnet”, “any_subnet”, “external”, or “ip_address”.
- Specify whether to use the reserved IP address as a virtual IP address (VIP) (“is_vip = true”) or not (“is_vip = false”).
- (optional) Add “allowed_access_pairs” to assign one VIP to multiple machines. Specify the “ip_address” and “mac_address”.
- (optional) Specify the “network_id” and/or “subnet_id” to attach the IP address to a specific network or subnetwork.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
Volumes
The following resources create and manage block storage volumes.Create a volume
The following configuration creates a standalone volume that can be attached to instances.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize:
- Configure the volume.
- Specify “name”.
- Specify the “snapshot_id” or “image_id”.
- (optional) Specify the “size” of the volume in GB.
- (optional) Select the “type_name”: “standard”, “ssd_hiiops”, “cold”, or “ultra”.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
Create a snapshot
The following configuration creates a snapshot of an existing volume.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the snapshot.
- Specify “name”.
- Specify the “volume_id”.
- (optional) Add a “description”.
- (optional) Specify the “region_id” and “region_name”.
- (optional) Specify the “project_id” and “project_name”.
Virtual Machines
The following resources create Virtual Machine instances and placement groups.Create a Virtual Machine
The following configuration creates a Virtual Machine with a reserved IP, boot volume, and floating IP attached.- Open the
main.tffile with the Gcore provider configuration. - Copy the code to the file and customize the highlighted values:
- Configure resources required for the Virtual Machine: reserved IP, network and subnetwork, volume.
- Configure the Virtual Machine.
- Specify “flavor_id”.
- Select the interface “type”: “external”, “subnet”, “any_subnet”, or “reserved_fixed_ip”.
- For “subnet” type, specify the “network_id” and “subnetwork_id”.
- For “any_subnet” type, specify the “network_id”.
- For “reserved_fixed_ip” type, specify the “port_id”.
- (optional) Add is_parent = “true” to prevent the interface from being detached and to set it as the first attached interface.
- (optional) Specify order to set the order in which interfaces will be attached.
- Configure “volume”.
- Specify “source = existing-volume” and the “volume_id”. Optionally, specify the size of the existing volume in GB.
- (optional) Specify the “boot_index”. If “boot_index = 0”, the volume cannot be detached.
- (optional) Specify the “type_name”: “standard”, “ssd_hiiops”, “cold”, or “ultra”.
- (optional) Add “allow_app_ports = true” to allow application ports for Virtual Machines created from marketplace templates.
- (optional) Specify “configuration” to set parameters for the application template from the marketplace: “key” and “value”.
- (optional) Specify the “keypair_name”.
- (optional) Specify the “metadata_map”: “key” and “value”.
- (optional) Specify the “name” of the Virtual Machine.
- (optional) Specify “username” and “password”.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- (optional) Specify the “security_group” to add firewalls.
Create a server group
The following configuration creates a server group with an affinity or anti-affinity placement policy.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the server group.
- Specify “name”.
- Select the
policy: use “affinity” to run servers on one physical server or “anti-affinity” to distribute servers across different physical servers. - (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
Bare Metal servers
The following resources provision Bare Metal servers and custom images.Create a Bare Metal server
The following configuration creates a Bare Metal server using the Gcore Terraform provider.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the Bare Metal server.
- Specify “flavor_id”.
- Configure “interface”.
- For “subnet” type, specify the “network_id” and “subnetwork_id”.
- For “any_subnet” type, specify the “network_id”.
- For “reserved_fixed_ip” type, specify the “port_id”.
- (optional) Specify “order” to set the order in which interfaces will be attached.
- (optional) Specify “app_config” to set parameters for the application template from the marketplace.
- (optional) Specify the “image_id” or “apptemplate_id”.
- (optional) Specify the “keypair_name”.
- (optional) Specify the “name” of the server.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- (optional) Specify the “metadata_map”: “key” and “value”.
- (optional) Specify “username” and/or “password”.
Create a GPU Bare Metal image
The following configuration uploads a custom image for use with GPU Bare Metal instances.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the Bare Metal image.
- “name” for the image.
- “url” where the image is located.
- “project_id” - The ID of the project. Conflicts with “project_name”.
- “project_name” - The name of the project. Conflicts with “project_id”.
- “region_id” - The ID of the region. Conflicts with “region_name”.
- “region_name” - The name of the region. Conflicts with “region_id”.
- “ssh_key” - SSH key permission setting. Valid values are:
- “allow” - (Default) Allow SSH key usage
- “deny” - Deny SSH key usage
- “required” - Require SSH key
- “cow_format” - When set to “true”, the image cannot be deleted until all volumes created from it are deleted.
- “architecture” - CPU architecture type. Valid values are:
- “x86_64” - (Default) x86 64-bit architecture
- “aarch64” - ARM 64-bit architecture
- “os_type” - The type of operating system.
- “os_distro” - The distribution of the operating system (e.g., “ubuntu”, “centos”).
- “os_version” - The version of the operating system.
- “hw_firmware_type” - The type of firmware used for booting.
- “metadata” - A map of metadata key-value pairs to associate with the image.
Kubernetes clusters
The following resources create and configure managed Kubernetes clusters.Create a managed Kubernetes cluster
The following configuration creates a Kubernetes cluster with a private network, subnet, and a single node pool.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the cluster.
- Specify “name”.
- Specify the “fixed_network” of the cluster.
- Specify the “fixed_subnet”; the subnet must have a router.
- Specify the “keypair”.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- (optional) Add
auto_healing_enabled = "true"to allow automatic recovery of failed nodes. - (optional) Add
external_dns_enabled = "true"to enable external DNS. - Configure the pool, a set of cluster nodes with the same specifications.
- Specify “name”.
- Specify “flavor_id”.
- Specify “servergroup_policy”. Server group policy: “anti-affinity”, “soft-anti-affinity”, or “affinity”.
- Specify the “min_node_count” for autoscaling.
- Specify the “max_node_count” for autoscaling.
- Specify the “node_count”. This is the initial number of nodes to be deployed.
- (optional) Specify the “boot_volume_size” in GB.
- (optional) Select “boot_volume_type”: “standard”, “ssd_hiiops”, “cold”, or “ultra”.
Create a Kubernetes cluster with Cilium load balancer and DSR
This configuration uses Cilium with Direct Server Return (DSR) mode, which preserves the client’s source IP — useful for logging, security, and latency-sensitive applications.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the cluster.
- Specify the Kubernetes “version”.
- Configure the “cni” (Container Network Interface) for the cluster. Specify the following parameters:
- lb_mode: The operation mode of load balancing for remote backends. Supported values are snat, dsr, hybrid. The default value is snat.
- routing_mode: Enables native-routing mode or tunneling mode. The default value is tunnel.
- Specify the “region_id” to define the data center location where the cluster is created.
- Specify the “project_id” to define the project in which the cluster is created.
- Specify the “name” to define the cluster name within the Gcore infrastructure.
- Specify the “keypair” to define the SSH key pair used for access to cluster nodes.
- Specify the “fixed_network” to define the ID of the network to which the Kubernetes cluster will be connected.
- Specify the “fixed_subnet” to define the ID of the subnet within the selected network.
- Configure the “pool” for the Kubernetes cluster. Specify the following parameters:
- name: Cluster pool name. Changing the value of this attribute will trigger recreation of the cluster pool.
- flavor_id: Cluster pool node flavor ID. Changing the value of this attribute will trigger recreation of the cluster pool.
- servergroup_policy: Server group policy, “anti-affinity”, “soft-anti-affinity”, or “affinity”.
- min_node_count: Minimum number of nodes in the cluster pool.
- max_node_count: Maximum number of nodes in the cluster pool.
- boot_volume_size: Cluster pool boot volume size. Applies to VM pools. Changing the value of this attribute will trigger recreation of the cluster pool.
- boot_volume_type: Cluster pool boot volume type. Applies to VM pools. Available values are “standard”, “ssd_hiiops”, “cold”, and “ultra”. Changing the value of this attribute will trigger recreation of the cluster pool.
Load Balancers
A Load Balancer consists of a balancer resource, one or more listeners, a pool, and members.Create a Load Balancer
The following configuration creates a Load Balancer with a listener, pool, and member.- Open the
main.tffile with the Gcore provider configuration. - Copy the code below to the file and customize the highlighted values:
- Configure the Load Balancer.
- Specify the “name” of the Load Balancer.
- Specify “flavor”.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- (optional) Specify the “vip_port_id” or “vip_network_id”.
- (optional) Specify the “vip_subnet_id”.
- Configure the listener.
- Specify “name”.
- Select “protocol”: “HTTP”, “HTTPS”, “TCP”, “UDP”, or “TERMINATED_HTTPS”. For “TERMINATED_HTTPS”, specify the “secret_id”.
- Specify the “protocol_port”.
- Specify the “loadbalancer_id”.
- (optional) Add
insert_x_forwarded = "true"to identify an original IP address of a client connecting to a web server via a load. - (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- Configure the pool.
- Specify “name”.
- Select “protocol”: “HTTP”, “HTTPS”, “TCP”, or “UDP”.
- Select “lb_algorithm”: “ROUND_ROBIN”, “LEAST_CONNECTIONS”, or “SOURCE_IP”.
- (optional) Add “health_monitor”.
- Select “type”: “HTTP”, “HTTPS”, “PING”, “TCP”, “TLS-HELLO”, or “UDP-CONNECT”.
- Specify the “delay” in seconds to set the time between sending probe requests to pool members.
- Specify the “max_retries” to set the number of successful probes required to switch a member to the ONLINE state.
- Specify the “timeout” in seconds to set the maximum time to connect.
- (optional) Select “http_method”: “CONNECT”, “DELETE”, “GET”, “HEAD”, “OPTIONS”, “PATCH”, “POST”, “PUT”, or “TRACE”.
- (optional) Specify the “max_retrieve_down” to set the threshold of failures required to switch a member to the ERROR state.
- (optional) Specify “expected_codes”.
- (optional) Specify the “url_path”.
- (optional) Specify the “listener_id”.
- (optional) Specify the “loadbalancer_id”.
- (optional) Specify the “region_id” or “region_name”.
- (optional) Specify the “project_id” or “project_name”.
- (optional) Add “session_persistence”.
- Select “type”: “APP_COOKIE”, “HTTP_COOKIE”
For “APP_COOKIE” or “HTTP_COOKIE”, specify the “cookie_name”.
For “SOURCE_IP”, specify the “persistence_granularity” (applies to UDP ports). - (optional) Specify the “persistence_timeout”.
- Select “type”: “APP_COOKIE”, “HTTP_COOKIE”
- Configure the member.
- Specify the IP “address”.
- Specify the “pool_id”.
- Specify the “protocol_port”.
- Specify the “instance_id” or “subnet_id”.
- (optional) Specify member “weight” from 0 to 256.