Skip to content

Commit

Permalink
Fix: Cloudformation Template - Forcing refresh of a TerraformVersion …
Browse files Browse the repository at this point in the history
…field
  • Loading branch information
TomerHeber committed Apr 3, 2024
1 parent 0444014 commit 3243222
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions env0/resource_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,18 @@ func templateRead(prefix string, template client.Template, d *schema.ResourceDat

path, pathOk := d.GetOk(pathPrefix)
terragruntTfBinary := d.Get(terragruntTfBinaryPrefix).(string)
terraformVersion := d.Get("terraform_version").(string)

// If this value isn't set, ignore whatever is returned from the response.
// This helps avoid drifts when defaulting to 'opentofu' for new 'terragrunt' templates, and 'terraform' for existing 'terragrunt' templates.
// 'template.TerragruntTfBinary' field is set to 'omitempty'. Therefore, the state isn't modified if `template.TerragruntTfBinary` is an empty string.
if terragruntTfBinary == "" {
template.TerragruntTfBinary = ""
}
// Same explanation as above.
if terraformVersion == "" {
template.TerraformVersion = ""
}

if err := writeResourceDataEx(prefix, &template, d); err != nil {
return fmt.Errorf("schema resource data serialization failed: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion tests/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
} else {
success, err := runTest(testName, destroyMode != "NO_DESTROY")
if !success {
log.Fatalln("Halting due to test failure:", err)
log.Fatalf("Halting due to test '%s' failure: %s\n", testName, err.Error())
}
}

Expand Down

0 comments on commit 3243222

Please sign in to comment.