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

Commit a741cac

Browse files
authored
Implement new policyset parameter_values syntax. Required provider 2.33.0 or above. (#24)
1 parent 28fc8e3 commit a741cac

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
azurerm = {
44
source = "hashicorp/azurerm"
5-
version = ">= 2.20.0"
5+
version = ">= 2.33.0"
66
}
77
}
88
required_version = ">= 0.13"

scripts/convertazopsreference.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ process_policysetdef() {
9696
echo " policy_definition_reference {"
9797
echo $dep | jq -r '" policy_definition_id = \"\(.policyDefinitionId)\""'
9898
echo $dep | jq -r '" reference_id = \"\(.policyDefinitionReferenceId)\""'
99-
echo " parameters = {"
100-
echo $dep | jq -r '.parameters | to_entries | .[] | " \(.key) = \"\(.value.value)\""'
101-
echo " }"
99+
echo " parameter_values = <<VALUES"
100+
echo $dep | jq -r '.parameters'
101+
echo "VALUES"
102102
echo " }"
103+
echo
103104
done)
104105
if [ ! "$POLICYSETPARAMETERS" == "{}" ] && [ ! "$POLICYSETPARAMETERS" == "null" ]; then
105106
local POLICYSETPARAMETERLINE=" parameters = <<PARAMETERS
@@ -119,7 +120,9 @@ resource "azurerm_policy_set_definition" "${TFNAME}" {
119120
depends_on = [
120121
$POLICYSETDEPS
121122
]
123+
122124
$POLICYDEFREFERENCE
125+
123126
$POLICYSETPARAMETERLINE
124127
}
125128
@@ -191,7 +194,7 @@ find $REFDIR -iname *policySetDefinitions* -print0 | xargs -0 -I % -n 1 -P 8 bas
191194

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

196199
# Terraform fmt
197200
if [ $(command -v terraform) ]; then

0 commit comments

Comments
 (0)