MagaluCloud / terraform-provider-mgc

Magalu Cloud terraform provider
https://docs.magalu.cloud/docs/terraform/overview
7 stars 1 forks source link

Falha em fazer o upgrade do provider mgc no módulo - Unable to unmarshal DynamicValue: unknown attribute "current_type" #10

Closed antonionovaesjr closed 4 months ago

antonionovaesjr commented 4 months ago

O que acontece ?

Ao tentar criar uma VM usando o provider 0.19.3 ocorre um erro

│ Error: ["current_current_type"]: unsupported attribute
│ 
│ 
╵
╷
│ Error: Unable to Convert State
│ 
│   with module.instance_se.mgc_block-storage_volumes.this["vdb"],
│   on ../main.tf line 33, in resource "mgc_block-storage_volumes" "this":
│   33: resource "mgc_block-storage_volumes" "this" {
│ 
│ An unexpected error was encountered when converting the state from the protocol type. This is always an issue in terraform-plugin-framework used to implement the provider and should be reported
│ to the provider developers.
│ 
│ Please report this to the provider developer:
│ 
│ Unable to unmarshal DynamicValue: unknown attribute "current_type"

O que é esperado ?

Criar virtual machine usando o código do módulo abaixo com a versão mais nova do provider: Módulo: https://registry.terraform.io/modules/terraform-magalu-cloud/virtual-machine/mgc/1.2.0

Como reproduzir:

variable "create" {
default = true
type = bool
}

variable "create" {
type = any
default = {
    vdb = {
      name = "opt"
      size = 10
      type = "cloud_nvme5k"
    },
    vdc = {
      name = "tmp"
      size = 10
      type = "cloud_nvme5k"
    }
 }
}

resource "mgc_block-storage_volumes" "this" {
  depends_on = [mgc_virtual-machine_instances.this]
  for_each   = var.create && length(var.additional_disk) > 0 ? var.additional_disk : {}
  name       = "${mgc_virtual-machine_instances.this[0].current_name}-${each.value.name}"
  size       = try(each.value.size, 10)
  type = {
    name = try(each.value.type, "cloud_nvme5k")
  }
}
antonionovaesjr commented 4 months ago

Segue o tfstate terraform.tfstate.zip

lfpicoloto1 commented 4 months ago

Fixed in the new version #27