Skip to content

Commit

Permalink
Validate policy mode value
Browse files Browse the repository at this point in the history
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
  • Loading branch information
beandrad committed Oct 8, 2020
1 parent f6568c9 commit 815a885
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions azurerm/internal/services/policy/policy_definition_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ func resourceArmPolicyDefinition() *schema.Resource {
"mode": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(
[]string{
"All",
"Indexed",
"Microsoft.ContainerService.Data",
"Microsoft.CustomerLockbox.Data",
"Microsoft.DataCatalog.Data",
"Microsoft.KeyVault.Data",
"Microsoft.Kubernetes.Data",
"Microsoft.MachineLearningServices.Data",
"Microsoft.Network.Data",
"Microsoft.Synapse.Data",
}, false,
),
},

"management_group_id": {
Expand Down

0 comments on commit 815a885

Please sign in to comment.