-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_policy_assignment policy_definition_id fails validation in 2.5, expects scope to be prepended #6523
Comments
Experiencing a similar issue after upgrading from azurem provider version 2.5 to 2.6 The below code works with azurerm 2.5
Workaround for 2.6 below.
|
Also experiencing similar issue after upgrading azurerm provider from v2.5 to v2.6 against all azurerm_policy_assignment resources. Error below Error: cannot parse "/providers/Microsoft.Authorization/policyDefinitions/ea3f2387-9b95-492a-a190-fcdc54f7b070" as a Policy Set Definition ID: unable to parse Policy Set Definition ID "/providers/Microsoft.Authorization/policyDefinitions/ea3f2387-9b95-492a-a190-fcdc54f7b070" |
I'm seeing the same issue.
|
Sorry about this.... This bug should be introduced by me, will have a look at this issue and possibly provide a fix for this issue. A possible workaround is that you can just remove the validation for Sorry again for the inconvenience! |
And some explanation for this behavior: But there is a flaw that I overlooked when writing the parsing function -- the built-in policy definitions actually do not have a scope part. Therefore when you are using a built-in policies the validation failure will pop out... |
This has been released in version 2.7.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.7.0"
}
# ... other configuration ... |
It looks to me like the same logic needs to be applied to the policySet parsing - https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/azurerm/internal/services/policy/parse/set_definition.go On the Policy Set I'm seeing - I'm getting cannot parse "/providers/Microsoft.Authorization/policySetDefinitions/1a5bb27d-173f-493e-9568-eb56638dde4d" as a Policy Set Definition ID: unable to parse Policy Set Definition ID "/providers/Microsoft.Authorization/policySetDefinitions/1a5bb27d-173f-493e-9568-eb56638dde4d": unable to parse Remediation Scope ID: ID is empty |
@jarmbruster74 - aye, I'm still getting the same error. |
@ArcturusZhang - would it be possible to add the same logic for the policy set defintion? Should we open a new issue? |
Oh I think a new issue works for me, since this has been closed. I will get it fixed as soon as possible... |
In the meantime, could you please provide some more context about the policy set that has issues here? Is it a built-in policy set? If so what is the display name of it? I am thinking about adding a new test case to cover this scenario |
The policyset that's failing validation is a built in policyset. I'll create a new issue. Thanks! |
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! |
This Terraform code works fine in 2.5 and older:
However, in 2.6 it fails with validation errors:
"unable to parse Policy Definition ID "/providers/Microsoft.Authorization/policyDefinitions/e56962a6-4747-49cd-b67b-bf8b01975c4c": unable to parse Remediation Scope ID: ID is empty" is the relevant error message here.
I tracked down a change in #6305 which adds validation to the field:
https://github.com/terraform-providers/terraform-provider-azurerm/blob/0488b7a3a097f4ea6dbd884e1395d88ede26e0c9/azurerm/internal/services/policy/resource_arm_policy_assignment.go#L62-L65
Reading up on the code that actually does this validation, I think this is what's causing the issue:
https://github.com/terraform-providers/terraform-provider-azurerm/blob/b7ae3e23f5f8c64a6c6f4da52421dbc34f46cdd9/azurerm/internal/services/policy/parse/definition.go#L15-L17
This expects there to be a
{scope}
part that occurs before "/providers/Microsoft.Authorization...", and the name of the policy to occur after. The name is present ("e56962a6-4747-49cd-b67b-bf8b01975c4c") but the scope is not.It seems like we're expected to duplicate what is already passed in as
scope
and prepend it topolicy_definition_id
. We can do this as a workaround, but is this intented behavior?The text was updated successfully, but these errors were encountered: