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_policy_set_definition/azurerm_policy_definition - Reverse the order of policies lookup to favour builtin #18338

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Changes from all commits
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
8 changes: 4 additions & 4 deletions internal/services/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ func getPolicyDefinitionByDisplayName(ctx context.Context, client *policy.Defini

func getPolicyDefinitionByName(ctx context.Context, client *policy.DefinitionsClient, name, managementGroupName string) (res policy.Definition, err error) {
if managementGroupName == "" {
res, err = client.Get(ctx, name)
res, err = client.GetBuiltIn(ctx, name)
if utils.ResponseWasNotFound(res.Response) {
res, err = client.GetBuiltIn(ctx, name)
res, err = client.Get(ctx, name)
}
} else {
res, err = client.GetAtManagementGroup(ctx, name, managementGroupName)
Expand All @@ -63,9 +63,9 @@ func getPolicyDefinitionByName(ctx context.Context, client *policy.DefinitionsCl

func getPolicySetDefinitionByName(ctx context.Context, client *policy.SetDefinitionsClient, name, managementGroupID string) (res policy.SetDefinition, err error) {
if managementGroupID == "" {
res, err = client.Get(ctx, name)
res, err = client.GetBuiltIn(ctx, name)
if utils.ResponseWasNotFound(res.Response) {
res, err = client.GetBuiltIn(ctx, name)
res, err = client.Get(ctx, name)
}
} else {
res, err = client.GetAtManagementGroup(ctx, name, managementGroupID)
Expand Down