Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_resource_group_template_deployment - output_content can now be referenced in other resources #25403

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
output_content can now be referenced in other resources
  • Loading branch information
mbfrahry committed Mar 25, 2024
commit d0634d3323c41259917da9fa72a4bf19f3c5dd68
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"log"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck
Expand Down Expand Up @@ -107,6 +108,22 @@ func resourceGroupTemplateDeploymentResource() *pluginsdk.Resource {
// parsing the JSON using `jsondecode` allows the users to interact with/map objects as required
},
},

// this is needed to fix https://github.com/hashicorp/terraform-provider-azurerm/issues/12828
// On a change to `template_content`, we'll set `output_content` to empty
// The adverse effect of this is that any change to `template_content` will also cause any resource referencing `output_content` to update
CustomizeDiff: func(ctx context.Context, d *pluginsdk.ResourceDiff, i interface{}) error {
if d.HasChange("template_content") {
o, n := d.GetChange("template_content")

// the json has to be normalized and then compared against to see if a change has occurred
if !strings.EqualFold(o.(string), utils.NormalizeJson(n)) {
return d.SetNewComputed("output_content")
}
}

return nil
},
}
}

Expand Down