The Gcore Terraform provider v2 is a complete rewrite generated from the Gcore OpenAPI specification, covering more resources and using more consistent attribute names. Migrating from v0 to v2 requires manual configuration updates because the two versions use incompatible resource names, attribute names, and authentication configuration.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.
Before migrating
v2 usesapi_key instead of permanent_api_token for authentication, adds a cloud_ prefix to all Cloud resource types, and changes the import ID separator from : to /. The reference tables for resource type renames and attribute changes are in the steps below where they are needed.
Resources without a v2 equivalent
The following v0 resources do not yet have a v2 equivalent. Keep them on v0, or manage them through the Gcore Customer Portal and API until v2 support is added:gcore_snapshotgcore_lifecyclepolicygcore_storage_s3/gcore_storage_s3_bucketgcore_storage_sftpgcore_faas_function/gcore_faas_key/gcore_faas_namespacegcore_laas_topicgcore_postgres_clustergcore_ddos_protectiongcore_port_security/gcore_port_allowed_address_pairsgcore_registry_credential
Migration approach
There is no automated migration tool, so the process is manual:- Back up the current state file.
- Remove each resource from Terraform state (without deleting it from Gcore).
- Update all
.tffiles to use v2 resource types and provider configuration. - Run
terraform init -upgradeto install the v2 provider. - Re-import each resource under its new v2 resource type.
- Run
terraform planand resolve any attribute drift.
Migrate each resource
The steps below use an SSH key pair as a concrete case. Apply the same steps to every other resource in the project — only the resource type and import ID format differ.Starting point: v0 configuration
The project has two files:providers.tf with the provider block and main.tf with a single SSH key resource.
providers.tf:
main.tf:
id value from terraform state show is the import ID needed in Step 6:
Step 1. Back up the state
Copy the state file before making any changes — if something goes wrong during migration, restoring this backup returns Terraform to its v0 state without touching the actual infrastructure:- PowerShell
- Bash / Zsh
- PowerShell
- Bash / Zsh
Step 2. Remove resources from state
Runterraform state list to see all tracked resources, then remove each one with terraform state rm. This removes resources from Terraform tracking only — the actual infrastructure in Gcore is not affected.
Only the local state file is modified; no Gcore API calls are made.
Step 3. Update providers.tf
Replace the v0 provider block with v2: v0:var.api_token was used in v0, rename it to var.api_key (or keep the existing name — the variable name is flexible; only the provider attribute must change to api_key).
To use an environment variable instead, update the name:
- PowerShell
- Bash / Zsh
Step 4. Update resource blocks in .tf files
Rename each resource type and update attributes that changed. Use the reference tables to find the v2 name for every v0 resource type and attribute.Cloud resource type renames
Cloud resource type renames
| v0 resource | v2 resource |
|---|---|
gcore_keypair | gcore_cloud_ssh_key |
gcore_instance / gcore_instancev2 | gcore_cloud_instance |
gcore_network | gcore_cloud_network |
gcore_subnet | gcore_cloud_network_subnet |
gcore_router | gcore_cloud_network_router |
gcore_volume | gcore_cloud_volume |
gcore_loadbalancer / gcore_loadbalancerv2 | gcore_cloud_load_balancer |
gcore_lblistener | gcore_cloud_load_balancer_listener |
gcore_lbpool | gcore_cloud_load_balancer_pool |
gcore_lbmember | gcore_cloud_load_balancer_pool_member |
gcore_k8sv2 | gcore_cloud_k8s_cluster |
gcore_securitygroup | gcore_cloud_security_group |
gcore_secret | gcore_cloud_secret |
gcore_reservedfixedip | gcore_cloud_reserved_fixed_ip |
gcore_floatingip | gcore_cloud_floating_ip |
gcore_servergroup | gcore_cloud_placement_group |
gcore_baremetal | gcore_cloud_baremetal_server |
gcore_file_share | gcore_cloud_file_share |
gcore_gpu_virtual_cluster | gcore_cloud_gpu_virtual_cluster |
CDN resource type renames
CDN resource type renames
| v0 resource | v2 resource |
|---|---|
gcore_cdn_resource | gcore_cdn_resource (unchanged) |
gcore_cdn_rule_template | gcore_cdn_rule_template (unchanged) |
gcore_cdn_origingroup | gcore_cdn_origin_group |
gcore_cdn_rule | gcore_cdn_resource_rule |
gcore_cdn_sslcert | gcore_cdn_certificate |
gcore_cdn_cacert | gcore_cdn_trusted_ca_certificate |
DNS, FastEdge, WAAP resource type renames
DNS, FastEdge, WAAP resource type renames
| v0 resource | v2 resource |
|---|---|
gcore_dns_zone | gcore_dns_zone (unchanged) |
gcore_dns_zone_record | gcore_dns_zone_rrset |
gcore_dns_network_mapping | gcore_dns_network_mapping (unchanged) |
gcore_fastedge_app | gcore_fastedge_app (unchanged) |
gcore_fastedge_binary | gcore_fastedge_binary (unchanged) |
gcore_fastedge_secret | gcore_fastedge_secret (unchanged) |
gcore_fastedge_template | gcore_fastedge_template (unchanged) |
gcore_waap_domain | gcore_waap_domain (unchanged) |
gcore_storage_sftp_key | gcore_storage_ssh_key |
Key attribute renames
Key attribute renames
| Resource | v0 attribute | v2 attribute |
|---|---|---|
gcore_keypair → gcore_cloud_ssh_key | sshkey_name | name |
gcore_keypair → gcore_cloud_ssh_key | sshkey_id (computed) | id (computed) |
gcore_keypair → gcore_cloud_ssh_key | project_id, public_key, fingerprint | unchanged |
gcore_network → gcore_cloud_network | name, type, region_id, project_id, create_router | unchanged |
gcore_subnet → gcore_cloud_network_subnet | name, cidr, network_id, region_id, project_id | unchanged |
gcore_subnet → gcore_cloud_network_subnet | dns_nameservers | unchanged |
gcore_volume → gcore_cloud_volume | name, size, type_name, region_id, project_id | unchanged |
sshkey_name renamed to name:
gcore_network.main.id, it now references gcore_cloud_network.main.id.
Step 5. Run terraform init -upgrade
Install the v2 provider:Step 6. Import each resource under its v2 type
The resource ID is the same UUID the resource had in v0 — find it in the state backup created in Step 1 by looking for the"id" field, or in the Customer Portal URL. Use terraform import with the v2 format (/ separator instead of : for Cloud resources):
Import ID formats for common Cloud resources
Common Cloud resource import ID formats:| v2 resource | Import ID format |
|---|---|
gcore_cloud_ssh_key | <project_id>/<ssh_key_id> |
gcore_cloud_network | <project_id>/<region_id>/<network_id> |
gcore_cloud_network_subnet | <project_id>/<region_id>/<subnet_id> |
gcore_cloud_instance | <project_id>/<region_id>/<instance_id> |
gcore_cloud_volume | <project_id>/<region_id>/<volume_id> |
gcore_cloud_load_balancer | <project_id>/<region_id>/<lb_id> |
gcore_cloud_k8s_cluster | <project_id>/<region_id>/<cluster_id> |
gcore_cloud_security_group | <project_id>/<region_id>/<sg_id> |
gcore_cloud_floating_ip | <project_id>/<region_id>/<fip_id> |
gcore_cloud_reserved_fixed_ip | <project_id>/<region_id>/<rfip_id> |
Step 7. Run terraform plan
After importing all resources, runterraform plan to check for attribute drift — differences between the imported state and the local configuration:
terraform plan shows changes, the resource block in the .tf file has attributes whose values do not match what the Gcore API returned after import. Update those attributes until terraform plan reports no changes. Common causes:
- An attribute set in v0 has a different name in v2 (see the attribute rename table above).
- A v2 computed attribute is now read-only and must be removed from the resource block.
- A v0 attribute was silently ignored but v2 enforces it strictly.
Migrating data sources
Data source types also changed. Update alldata blocks alongside the resource blocks:
Data source rename reference
Data source rename reference
| v0 data source | v2 data source |
|---|---|
data "gcore_project" | data "gcore_cloud_project" |
data "gcore_region" | data "gcore_cloud_region" |
data "gcore_image" | data "gcore_cloud_image" |
data "gcore_network" | data "gcore_cloud_network" |
data "gcore_subnet" | data "gcore_cloud_network_subnet" |
data "gcore_volume" | data "gcore_cloud_volume" |
data "gcore_instance" | data "gcore_cloud_instance" |
data "gcore_k8s" | data "gcore_cloud_k8s_cluster" |
data "gcore_loadbalancer" | data "gcore_cloud_load_balancer" |
data "gcore_securitygroup" | data "gcore_cloud_security_group" |
data "gcore_floatingip" | data "gcore_cloud_floating_ip" |
.tf files and update any references.