Skip to content

Commit 815a885

Browse files
committed
Validate policy mode value
Policy creation succeeds even if the policy mode in the request is not capitalized, however, when fetching the policy mode value from Azure, the correct capitalized version is returned, which causes the Terraform state and configuration to be different. Ideally, there should be an enum with a set of allowed values, but this is not the case in the latest version of the Azure Rest API specs. However, the supported mode values are returned in the error response when an invalid mode is requested. Fixes #8748
1 parent f6568c9 commit 815a885

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

azurerm/internal/services/policy/policy_definition_resource.go

+14
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ func resourceArmPolicyDefinition() *schema.Resource {
6363
"mode": {
6464
Type: schema.TypeString,
6565
Required: true,
66+
ValidateFunc: validation.StringInSlice(
67+
[]string{
68+
"All",
69+
"Indexed",
70+
"Microsoft.ContainerService.Data",
71+
"Microsoft.CustomerLockbox.Data",
72+
"Microsoft.DataCatalog.Data",
73+
"Microsoft.KeyVault.Data",
74+
"Microsoft.Kubernetes.Data",
75+
"Microsoft.MachineLearningServices.Data",
76+
"Microsoft.Network.Data",
77+
"Microsoft.Synapse.Data",
78+
}, false,
79+
),
6680
},
6781

6882
"management_group_id": {

0 commit comments

Comments
 (0)