You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For a "Single destination" redirect, the redirect.pizza API represents the destination field as a string, but the Terraform provider state represents it as an array of { url, expression, monitoring } objects.
The default value of the monitoring property for a destination object in Terraform is specified here to be inherit. But when read from the API, the value of "monitoring" is empty here -- which will cause the terraform plan to try to change the empty value to inherit, which the API will ignore because there is only one destination, which will cause Terraform to read the "empty" value from the API again, etc.
because there is no terraform-side validation that monitoring be one of the valid values, and it successfully considers the un-set value from the API equivalent to the provided empty string.
Potential Fixes
When converting a "Single" destination from a string to a list of objects, we could treat it as if the monitoring property were the default value of inherit (matching the API to the Terraform state).
Alternately, we could disallow setting the monitoring property (or the expression property) when there is only one destination block and store the value as empty (matching Terraform state to the API) in the Terraform state, better matching what one can express in Terraform configuration to what the API expects.
The text was updated successfully, but these errors were encountered:
Freeaqingme
added a commit
to Freeaqingme/terraform-provider-redirectpizza
that referenced
this issue
May 29, 2024
Thank you for reporting this issue! I must have seen it before, but while focusing on the big things, my brain must have kinda ignored it. I've prepared a fix in #57 , which my colleague will probably deploy as a new version this week still.
Summary
For a "Single destination" redirect, the redirect.pizza API represents the
destination
field as a string, but the Terraform provider state represents it as an array of{ url, expression, monitoring }
objects.The default value of the
monitoring
property for adestination
object in Terraform is specified here to beinherit
. But when read from the API, the value of "monitoring" is empty here -- which will cause the terraform plan to try to change the empty value toinherit
, which the API will ignore because there is only one destination, which will cause Terraform to read the "empty" value from the API again, etc.To Reproduce
Terraform
Steps to Reproduce
terraform init
terraform apply
i. Observe the
monitoring = "inherit"
in thedestination
block in the planterraform apply
againExpected
No Changes
Actual
It was not able to set the value of
monitoring
toinherit
in the originalapply
, so it tries to do so again, ad infinitum.Workaround
This does not work either, as Terraform interprets
null
as "use the default from the provider":However, this will round-trip properly:
because there is no terraform-side validation that
monitoring
be one of the valid values, and it successfully considers the un-set value from the API equivalent to the provided empty string.Potential Fixes
When converting a "Single" destination from a string to a list of objects, we could treat it as if the
monitoring
property were the default value ofinherit
(matching the API to the Terraform state).Alternately, we could disallow setting the
monitoring
property (or theexpression
property) when there is only onedestination
block and store the value as empty (matching Terraform state to the API) in the Terraform state, better matching what one can express in Terraform configuration to what the API expects.The text was updated successfully, but these errors were encountered: