Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate policy mode value #8795

Merged
merged 1 commit into from
Oct 8, 2020

Conversation

beandrad
Copy link
Contributor

@beandrad beandrad commented Oct 8, 2020

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
thi is not the case in the latest version of the Azure Rest API specs.
However, the supported mode values are returned in the create error
response when an invalid mode is requested.

Fixes #8748

@ghost ghost added the size/XS label Oct 8, 2020
@beandrad
Copy link
Contributor Author

beandrad commented Oct 8, 2020

Screenshot 2020-10-08 at 12 11 25

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @beandrad

Thanks for this PR - if we can also update the docs then this otherwise LGTM 👍

Thanks!

"Microsoft.MachineLearningServices.Data",
"Microsoft.Network.Data",
"Microsoft.Synapse.Data",
}, false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we also update the values used in the docs here: https://github.com/terraform-providers/terraform-provider-azurerm/blame/master/website/docs/r/policy_definition.html.markdown#L72-L74

* `mode` - (Required) The policy mode that allows you to specify which resource types will be evaluated. Possible values are `All`, `Indexed`, `Microsoft.ContainerService.Data`, `Microsoft.CustomerLockbox.Data`, `Microsoft.DataCatalog.Data`, `Microsoft.KeyVault.Data`, `Microsoft.Kubernetes.Data`, `Microsoft.MachineLearningServices.Data`, `Microsoft.Network.Data` and `Microsoft.Synapse.Data`.

@Nepomuceno
Copy link
Contributor

I do think that a DiffSupress Would be better for this them forcing the values.

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 hashicorp#8748
@beandrad
Copy link
Contributor Author

beandrad commented Oct 8, 2020

@tombuildsstuff thanks for reviewing! docs updated!

@jackofallops jackofallops merged commit 5ab0421 into hashicorp:master Oct 8, 2020
jackofallops added a commit that referenced this pull request Oct 8, 2020
@ghost
Copy link

ghost commented Oct 8, 2020

This has been released in version 2.31.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.31.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Nov 8, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Nov 8, 2020
@beandrad beandrad deleted the 8748-policy-definition branch November 9, 2020 09:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

azurerm_policy_definition mode is case sensitive
4 participants