Skip to content

Commit 9134c59

Browse files
authored
Fix: resource 'env0_environment_scheduling' does not pass destroy_cron=null on updates (#842)
1 parent 5abb4d4 commit 9134c59

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

env0/resource_environment_scheduling.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func resourceEnvironmentSchedulingCreateOrUpdate(ctx context.Context, d *schema.
6969
return diag.Errorf("schema resource data deserialization failed: %v", err)
7070
}
7171

72+
if payload.Deploy != nil && !payload.Deploy.Enabled {
73+
payload.Deploy = nil
74+
}
75+
76+
if payload.Destroy != nil && !payload.Destroy.Enabled {
77+
payload.Destroy = nil
78+
}
79+
7280
if _, err := apiClient.EnvironmentSchedulingUpdate(environmentId, payload); err != nil {
7381
return diag.Errorf("could not create or update environment scheduling: %v", err)
7482
}

tests/integration/014_environment_scheduling/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ resource "env0_environment" "environment" {
3434
resource "env0_environment_scheduling" "scheduling" {
3535
environment_id = env0_environment.environment.id
3636
deploy_cron = "5 * * * *"
37-
destroy_cron = "10 * * * *"
37+
destroy_cron = var.second_run ? null : "10 * * * *"
3838
}

0 commit comments

Comments
 (0)