Mastercard / terraform-provider-restapi

A terraform provider to manage objects in a RESTful API
Other
785 stars 215 forks source link

Error: internal validation failed; object ID is not set, but may have been created; this should never happen #257

Open japerrin opened 6 months ago

japerrin commented 6 months ago

Hi

I tried to create a VMware NSX-V "logical switch" object with: resource "restapi_object" "create_logical_switch" { path = "/api/2.0/vdn/scopes/${local.transport_zone_id}/virtualwires" read_path = "/api/2.0/vdn/virtualwires" data = local.body_json object_id = "*" }

locals {

Build body

body = { name = var.logical_switch_name, description = var.logical_switch_description, tenantId = local.tenant_id, guestVlanAllowed = false }

body_json = jsonencode(local.body)
}

The URI is different to create object and get its properties, so I set the path and read_path.

I have an issue when I create the object, the NSX-V API return the id BUT the ID is returned as raw like: "virtualwire-12"

and not formated like:
{"id": "virtualwire-12"}

So I have the error message: Error: internal validation failed; object ID is not set, but may have been created; this should never happen

The object is created but terraform return an error

How can I do to reformat the response raw from "virtualwire-12" to {"id": "virtualwire-12"} ?

Thanks a lot Jacques

S3B4SZ17 commented 4 months ago

Hi @japerrin I created the above PR adding that functionality. Please feel free to review it and share any thoughts.