OpsLevel / terraform-provider-opslevel

Terraform provider for OpsLevel.com
https://registry.terraform.io/providers/OpsLevel/opslevel/latest/docs
MIT License
8 stars 5 forks source link

Problem with creating domain without owner #390

Closed rocktavious closed 3 weeks ago

rocktavious commented 1 month ago

A customer reported

trying to use your Terraform provider to create Domains in our account. Issue is that I was trying to create them without an owner, as it's still not defined within the organisation.

I first tried to set them as an empty string, was met with this error:
Error: Config error
│ 
│   with opslevel_domain.XXX_domain["quote"],
│   on domains.tf line 1, in resource "opslevel_domain" "XXX_domain":
│    1: resource "opslevel_domain" "XXX_domain" {
│ 
│ expected a valid id. id should start with Z2lkOi8v. 'owner' was set to 

I then proceeded to set them to null and was met with the following:

Error: Provider produced inconsistent result after apply
│ 
│ When applying changes to opslevel_domain.XXX_domain["retail-user"],
│ provider "provider[\"registry.terraform.io/opslevel/opslevel\"]" produced
│ an unexpected new value: .description: was cty.StringVal(""), but now null.
│ 
│ This is a bug in the provider, which should be reported in the provider's
│ own issue tracker.
davidbloss commented 3 weeks ago

There wasn't actually an issue with creating a Domain with no owner, just a misunderstanding. The owner field in a Domain cannot be an empty string. To make this clearer, I added a Config error that reads expected a valid id but given an empty string. please set to 'null' or an id starting with 'Z2lkOi8v'

There was an issue with optional description fields across numerous resources. The provider wasn't able to reliably handle an empty string vs a null resulting in this error: produced an unexpected new value: .description: was cty.StringVal(""), but now null. This has been fixed in this PR