I am implementing a Terraform provider using the Terraform Plugin Framewok.
I have an issue with a resource. Here is a dummy example :
resource "dummy_resource" "dummy" {
category = "A" // Can be A, B or C
performance = "high" // Can be high, medium or low
}
The API to create a Dummy resource have 2 configurable fields, category
and performance
. In this API (that I can’t modify), there is the following rule :
- If
category == A
the given performance field will be ignored andperformance
will be set tohigh
Note : In my real use case, there is multiple rules that can change over time so I can’t know exactly what the rules will be.
The issue I have here is that, if a user uses the following configuration
resource "dummy_resource" "dummy" {
category = "A"
performance = "low"
}
The API will not use the given performance field and set performance
to high
resulting in the following error :
Error: Provider produced inconsistent result after apply
When applying changes to dummy_resource.dummy, provider
"provider["registry.terraform.io/hashicorp/my_provider"]" produced an
unexpected new value: .performance: was cty.StringVal("low"), but now
cty.StringVal("high").
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
In order to avoid this error, I would like to prevent Terraform from checking the performance
field value as I can never be sure the API will use the given value.
Is it possible to do that? And how ?