IBM-Cloud / terraform-provider-ibm

https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs
Mozilla Public License 2.0
340 stars 667 forks source link

[Cloudant] Booleans are not respected in `parameters` block #5339

Open eiri opened 4 months ago

eiri commented 4 months ago

Community Note

Terraform CLI and Terraform IBM Provider Version

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "ibm_cloudant" "cloudant_instance" {
 count = var.provision ? 1 : 0
 name        = var.instance_name
 plan        = var.plan
 location      = var.region
 resource_group_id = var.resource_group_id
 legacy_credentials = var.legacy_credentials
 tags        = (var.tags != null ? var.tags : [])
 service_endpoints = (var.service_endpoints != "" ? var.service_endpoints : null)
 //User can increase timeouts
 timeouts {
  create = (var.create_timeout != null ? var.create_timeout : null)
  update = (var.update_timeout != null ? var.update_timeout : null)
  delete = (var.delete_timeout != null ? var.delete_timeout : null)
 }
 parameters = {
  onetime_credentials = false
 }
}

Debug Output

Panic Output

Expected Behavior

Created resource should have parameter onetime_credentials set to false

Actual Behavior

Created resource should have parameter onetime_credentials equal true

Steps to Reproduce

  1. terraform apply

Important Factoids

References

eiri commented 4 months ago

According code block that should've work is here https://github.com/IBM-Cloud/terraform-provider-ibm/blob/master/ibm/service/resourcecontroller/resource_ibm_resource_instance.go#L495

There are a section that casts string "true" and "false" to boolean, so that might've been in play instead, depends on how serialized parameters are passed to controller.

Another question to investigate is Cloudant controller accepts false as parameter for onetime_credentials on creation of resource, as that would expect to be a default, or is it an upgrade parameter.

While on this topic it would be beneficial to investigate if parameter parameters_json works in this case, e.g.

parameters_json = jsonencode(
    {
      "onetime_credentials" : false
    }
  )

or

parameters_json = <<PARAMETERS_JSON
      {
        "onetime_credentials" : false
      } 
      PARAMETERS_JSON 

and update an example section for the resource accordingly.