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

update policy def datasource docs and error messages #20510

Merged
merged 4 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ FEATURES:
ENHANCEMENTS:

* `azurerm_api_management_named_value` - support for system managed identities ([#12938](https://github.com/hashicorp/terraform-provider-azurerm/issues/12938))
* `azurerm_application_insights_smart_detection_rule` - support all currenly availible rules in the SDK ([#12857](https://github.com/hashicorp/terraform-provider-azurerm/issues/12857))
* `azurerm_application_insights_smart_detection_rule` - support all currently available rules in the SDK ([#12857](https://github.com/hashicorp/terraform-provider-azurerm/issues/12857))
* `azurerm_function_app` - add support for `dotnet_framework_version` in ([#12883](https://github.com/hashicorp/terraform-provider-azurerm/issues/12883))
* `azurerm_resource_group` - conditionally (based on the `prevent_deletion_if_contains_resources` features flag - see the 'Upgrade Notes' section) checking for nested Resources during deletion of the Resource Group and raising an error if Resources are found ([#12657](https://github.com/hashicorp/terraform-provider-azurerm/issues/12657))

Expand Down
4 changes: 2 additions & 2 deletions internal/services/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func getPolicyDefinitionByDisplayName(ctx context.Context, client *policy.Defini

// we found none
if len(results) == 0 {
return policy.Definition{}, fmt.Errorf("loading Policy Definition List: could not find policy '%s'", displayName)
return policy.Definition{}, fmt.Errorf("loading Policy Definition List: could not find policy '%s'. has the policies name changed? list available with `az policy definition list`", displayName)
}

// we found more than one
if len(results) > 1 {
return policy.Definition{}, fmt.Errorf("loading Policy Definition List: found more than one policy '%s'", displayName)
return policy.Definition{}, fmt.Errorf("loading Policy Definition List: found more than one (%d) policy '%s'", len(results), displayName)
}

return results[0], nil
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/policy_definition.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ output "id" {

* `display_name` - Specifies the display name of the Policy Definition. Conflicts with `name`.

~> **NOTE** As `display_name` is not unique errors may occur when there are multiple policy definitions with same display name.
~> **NOTE** Looking up policies by `display_name` is not recommended by the Azure Policy team as the property is not unique nor immutable. As such errors may occur when there are multiple policy definitions with same display name or the display name is changed. To avoid these types of errors you may wish to use the `name` property instead.

* `management_group_name` - (Optional) Only retrieve Policy Definitions from this Management Group.

Expand Down