Open
Description
terraform version
Terraform v1.5.7
on darwin_arm64
+ provider registry.terraform.io/g-core/gcore v0.3.82
config file
terraform {
required_providers {
gcore = {
source = "G-Core/gcore"
}
}
}
provider "gcore" {
permanent_api_token = <API_TOKEN>
}
variable "gcore_project_id" {
type = number
default =<PROJECT>
}
variable "gcore_regions" {
type = list(string)
default = [
"Luxembourg-2",
]
}
variable "instances" {
type = list(object({
name = string
region = string
flavor_id = string
volumn_type = string
}))
default = [
{
name = "testing-lux-1"
region = "Luxembourg-2"
flavor_id = "g1-standard-2-4"
volumn_type = "ssd_hiiops"
},
]
}
data "gcore_region" "region_ids" {
for_each = toset(var.gcore_regions)
name = each.key
}
data "gcore_image" "ubuntu" {
for_each = toset(var.gcore_regions)
project_id = var.gcore_project_id
region_id = data.gcore_region.region_ids[each.key].id
name = "ubuntu-20.04-x64"
}
resource "gcore_reservedfixedip" "public" {
for_each = {
for instance in var.instances : instance.name => instance
}
project_id = var.gcore_project_id
region_id = data.gcore_region.region_ids[each.value.region].id
type = "external"
is_vip = false
}
resource "gcore_volume" "system_volumns" {
for_each = {
for instance in var.instances : instance.name => instance
}
project_id = var.gcore_project_id
region_id = data.gcore_region.region_ids[each.value.region].id
name = "System"
type_name = each.value.volumn_type
size = 20
image_id = data.gcore_image.ubuntu[each.value.region].id
}
resource "gcore_instance" "servers" {
for_each = {
for instance in var.instances : instance.name => instance
}
project_id = var.gcore_project_id
region_id = data.gcore_region.region_ids[each.value.region].id
name = each.value.name
flavor_id = each.value.flavor_id
volume {
source = "existing-volume"
volume_id = gcore_volume.system_volumns[each.key].id
boot_index = 0
}
interface {
type = "reserved_fixed_ip"
port_id = gcore_reservedfixedip.public[each.key].port_id
}
}
reproduce steps
- run
terraform apply
with the above config file, it reports 3 resources created and everything is OK. - change
gcore_image
toubuntu-22.04-x64
and runterraform apply
, then terraform will destroy 1 resource, create 1 resource and change 1 resource.
An error occurred while executing the terraform apply
command.
gcore_volume.system_volumns["testing-lux-1"]: Destroying... [id=bc562b75-780d-4d0b-a2b4-5ce2eb70a754]
│ Error: task is in error state: ERROR. Error: Invalid volume: Volume must not be migrating, attached, belong to a group, have snapshots or be disassociated from snapshots after volume transfer. (HTTP 400) (Request-ID: req-6dc67ba9-28b8-48ac-b0f9-616852e5b9c1)