Context: I am implementing (my first) Terraform plugin/provider as a wrapper towards existing public API.
One of the create operations in the API specifies an integer field which takes positive values or -1
serving as a default. If you specify -1
in the create API call, the value gets replaced by some default on the server side (say field = 1000
) and is stored as 1000
from now on.
If I present this to my Terraform plugin (terraform apply
):
resource "something" "mysomething" {
name = "someName"
field = -1
}
the call is not idempotent. Terraform continues to see a drift and subsequently offers:
# something.mysomething will be updated in-place
~ resource "something" "mysomething" {
id = "165-1567498530352"
name = "someName"
~ field = 1000 -> -1
}
Plan: 0 to add, 1 to change, 0 to destroy.
How to deal with such API?