gettek / terraform-azurerm-policy-as-code

Terraform modules that simplify the workflow of custom and built-in Azure Policies

Home Page:https://learn.microsoft.com/en-us/azure/governance/policy/concepts/policy-as-code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support discovery of policy file in local file path

timwebster9 opened this issue · comments

Issue Template

Prerequisites

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Context

  • Module Version: 2.6.0
  • Terraform Version: 1.2.3
  • AzureRM Provider Version: 3.10.0
# add code here

Expected Behavior

The definition module should be able to find the policy file using the category and policy name if you are using the modules from the registry and have your own policy definition files.

Also, if the consuming repo has a policy definition of the same name as one in this repo, it will use the the one in this repo.

Current Behavior

You need to provide a file path if your policy definition files aren't part of the module in the remote registry

Possible Solution

Add another argument to this coalesce function to check the root module path on the local disk using the same logic (policies/category/policy_name.json). Would suggest it first checks in the local repo for the existence of the policy file, then the file path argument, and finally this module.

This way we don't have to provide a file path for local policy definitions and can take advantage of the file discovery logic included in this module.