Describe the bug
env0_environment_discovery_configuration shows perpetual drift on retries_on_deploy (and related retry fields): every terraform plan / tofu plan reports an in-place update such as retries_on_deploy = 0 -> 2 even immediately after a successful apply.
The value does not appear to stick in Terraform state because the provider read path sets retries_on_deploy to 0 when the Env0 API returns no retry.onDeploy object, while the configured value remains 2 (or whatever was set in HCL).
This looks like a mismatch between write and read for the environment discovery API: the provider sends retry.onDeploy on PUT, but GET (and/or the PUT response) often omits it, so templateReadRetryOnHelper maps nil → 0 in state.
Note: 0 is not a valid configured retry count per ValidateRetries (allowed range is 1–3); it appears to be a sentinel for “unset from API,” not the actual remote value.
To Reproduce
Steps to reproduce the behavior.
- Configure environment discovery with
retries_on_deploy set (e.g. 2).
- Run
terraform apply (or tofu apply) and confirm the update succeeds.
- Run
terraform plan again with no config changes.
- Observe the same diff on
retries_on_deploy every time.
Optional verification after apply:
terraform state show 'env0_environment_discovery_configuration.example'
# retries_on_deploy = 0 (even though HCL has 2)
Minimal Terraform snippet:
terraform {
required_providers {
env0 = {
source = "env0/env0"
version = "~> 1.0" # e.g. 1.29.x — fill in your exact version below
}
}
}
resource "env0_project" "example" {
name = "example-project"
}
resource "env0_environment_discovery_configuration" "example" {
project_id = env0_project.example.id
glob_pattern = "**/terragrunt.hcl"
repository = "https://github.com/org/repo"
type = "terragrunt"
terragrunt_version = "0.54.0"
opentofu_version = "1.6.0"
terragrunt_tf_binary = "opentofu"
is_terragrunt_run_all = true
retries_on_deploy = 2
}
Expected behavior
After a successful apply:
- Terraform state should reflect
retries_on_deploy = 2.
- A subsequent plan should show no change for
retries_on_deploy.
- The Env0 API GET for
/environment-discovery/projects/{projectId} should return retry.onDeploy.times (or equivalent) matching what was sent on PUT.
Alternatively, if the environment discovery API does not support deploy/destroy retries, the provider should not expose those attributes on env0_environment_discovery_configuration, or should document that they are write-only / unsupported so users can avoid perpetual drift.
Provider Version
1.31.1
# terraform plan (after successful apply)
# env0_environment_discovery_configuration.example will be updated in-place
~ resource "env0_environment_discovery_configuration" "example" {
id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
~ retries_on_deploy = 0 -> 2
# (N unchanged attributes hidden)
}
Additional context
- Suspected read-path behavior in
templateReadRetryOnHelper (env0/resource_template.go): when retryOn == nil, the provider calls d.Set("retries_on_deploy", 0).
env0_environment_discovery_configuration uses this helper in setResourceEnvironmentDiscoveryConfiguration after GetEnvironmentDiscovery / PutEnvironmentDiscovery.
- Client model:
EnvironmentDiscoveryPayload.Retry is TemplateRetry with json:"retry"; deploy retries are under retry.onDeploy.times.
- API endpoint:
PUT / GET /environment-discovery/projects/{projectId}.
- The same
retries_on_deploy setting on env0_template may work correctly; drift appears specific to environment discovery configuration.
- Workaround today:
lifecycle { ignore_changes = [retries_on_deploy, ...] } on the discovery resource, or only set retries on the template.
Related code references (provider repo):
env0/resource_environment_discovery_configuration.go — templateReadRetryOnHelper / templateCreatePayloadRetryOnHelper on read/write
env0/resource_template.go — templateReadRetryOnHelper sets 0 when API returns nil
client/environment_discovery.go — EnvironmentDiscoveryPutPayload.Retry / EnvironmentDiscoveryPayload.Retry
Describe the bug
env0_environment_discovery_configurationshows perpetual drift onretries_on_deploy(and related retry fields): everyterraform plan/tofu planreports an in-place update such asretries_on_deploy = 0 -> 2even immediately after a successful apply.The value does not appear to stick in Terraform state because the provider read path sets
retries_on_deployto0when the Env0 API returns noretry.onDeployobject, while the configured value remains2(or whatever was set in HCL).This looks like a mismatch between write and read for the environment discovery API: the provider sends
retry.onDeployon PUT, but GET (and/or the PUT response) often omits it, sotemplateReadRetryOnHelpermapsnil→0in state.Note:
0is not a valid configured retry count perValidateRetries(allowed range is 1–3); it appears to be a sentinel for “unset from API,” not the actual remote value.To Reproduce
Steps to reproduce the behavior.
retries_on_deployset (e.g.2).terraform apply(ortofu apply) and confirm the update succeeds.terraform planagain with no config changes.retries_on_deployevery time.Optional verification after apply:
Minimal Terraform snippet:
Expected behavior
After a successful apply:
retries_on_deploy = 2.retries_on_deploy./environment-discovery/projects/{projectId}should returnretry.onDeploy.times(or equivalent) matching what was sent on PUT.Alternatively, if the environment discovery API does not support deploy/destroy retries, the provider should not expose those attributes on
env0_environment_discovery_configuration, or should document that they are write-only / unsupported so users can avoid perpetual drift.Provider Version
1.31.1
Additional context
templateReadRetryOnHelper(env0/resource_template.go): whenretryOn == nil, the provider callsd.Set("retries_on_deploy", 0).env0_environment_discovery_configurationuses this helper insetResourceEnvironmentDiscoveryConfigurationafterGetEnvironmentDiscovery/PutEnvironmentDiscovery.EnvironmentDiscoveryPayload.RetryisTemplateRetrywithjson:"retry"; deploy retries are underretry.onDeploy.times.PUT/GET/environment-discovery/projects/{projectId}.retries_on_deploysetting onenv0_templatemay work correctly; drift appears specific to environment discovery configuration.lifecycle { ignore_changes = [retries_on_deploy, ...] }on the discovery resource, or only set retries on the template.Related code references (provider repo):
env0/resource_environment_discovery_configuration.go—templateReadRetryOnHelper/templateCreatePayloadRetryOnHelperon read/writeenv0/resource_template.go—templateReadRetryOnHelpersets0when API returnsnilclient/environment_discovery.go—EnvironmentDiscoveryPutPayload.Retry/EnvironmentDiscoveryPayload.Retry