Skip to content

Commit

Permalink
Fix: Cloudformation Template - Forcing refresh of a TerraformVersion … (
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber committed Apr 5, 2024
1 parent 0444014 commit dc3d675
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions env0/resource_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,21 +426,28 @@ func templateCreatePayloadFromParameters(prefix string, d *schema.ResourceData)
func templateRead(prefix string, template client.Template, d *schema.ResourceData) error {
pathPrefix := "path"
terragruntTfBinaryPrefix := "terragrunt_tf_binary"
terraformVersionPrefix := "terraform_version"

if prefix != "" {
pathPrefix = prefix + ".0." + pathPrefix
terragruntTfBinaryPrefix = prefix + ".0." + terragruntTfBinaryPrefix
terraformVersionPrefix = prefix + ".0." + terraformVersionPrefix
}

path, pathOk := d.GetOk(pathPrefix)
terragruntTfBinary := d.Get(terragruntTfBinaryPrefix).(string)
terraformVersion := d.Get(terraformVersionPrefix).(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 dc3d675

Please sign in to comment.