Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Implement new policyset parameter_values syntax. Required provider 2.…
Browse files Browse the repository at this point in the history
…33.0 or above. (#24)
  • Loading branch information
matt-FFFFFF authored Jan 5, 2021
1 parent 28fc8e3 commit a741cac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.20.0"
version = ">= 2.33.0"
}
}
required_version = ">= 0.13"
Expand Down
11 changes: 7 additions & 4 deletions scripts/convertazopsreference.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ process_policysetdef() {
echo " policy_definition_reference {"
echo $dep | jq -r '" policy_definition_id = \"\(.policyDefinitionId)\""'
echo $dep | jq -r '" reference_id = \"\(.policyDefinitionReferenceId)\""'
echo " parameters = {"
echo $dep | jq -r '.parameters | to_entries | .[] | " \(.key) = \"\(.value.value)\""'
echo " }"
echo " parameter_values = <<VALUES"
echo $dep | jq -r '.parameters'
echo "VALUES"
echo " }"
echo
done)
if [ ! "$POLICYSETPARAMETERS" == "{}" ] && [ ! "$POLICYSETPARAMETERS" == "null" ]; then
local POLICYSETPARAMETERLINE=" parameters = <<PARAMETERS
Expand All @@ -119,7 +120,9 @@ resource "azurerm_policy_set_definition" "${TFNAME}" {
depends_on = [
$POLICYSETDEPS
]
$POLICYDEFREFERENCE
$POLICYSETPARAMETERLINE
}
Expand Down Expand Up @@ -191,7 +194,7 @@ find $REFDIR -iname *policySetDefinitions* -print0 | xargs -0 -I % -n 1 -P 8 bas

# Replace MG prefix if specified
echo "Changing policyDefinitions refs in policysets"
find $OUTDIR -iname \*policyset\*.tf | xargs -n 1 -P 8 sed -i 's/\/contoso\//\/${var.management_group_name}\//g'
find $OUTDIR -iname \*policyset\*.tf | xargs -n 1 -P 8 sed -i 's/\/ESLZ\//\/${var.management_group_name}\//g'

# Terraform fmt
if [ $(command -v terraform) ]; then
Expand Down

0 comments on commit a741cac

Please sign in to comment.