-
Notifications
You must be signed in to change notification settings - Fork 585
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
Bug Report: Lacking permissions in default policy Deploy-Private-DNS-Zones #794
Comments
I digged a little deeper and found three role assignments looking at my terraform state: tf state list | grep 'Deploy-Private' I got three role assignments similar to this one: module.caf-enterprise-scale.module.role_assignments_for_policy["/providers/Microsoft.Management/managementGroups/slcorp-corp/providers/Microsoft.Authorization/policyAssignments/Deploy-Private-DNS-Zones"].azurerm_role_assignment.for_policy["/providers/Microsoft.Management/managementGroups/slcorp-corp/providers/Microsoft.Authorization/roleAssignments/31cc3591-0000-565f-ba5f-8adaf847da5d"] By inspecting the state, I found that those three role assignments are: role_definition_name = "Private DNS Zone Contributor"
scope = "/providers/Microsoft.Management/managementGroups/slcorp-corp"
role_definition_name = "Network Contributor"
scope = "/providers/Microsoft.Management/managementGroups/slcorp-corp"
role_definition_name = "Contributor"
scope = "/providers/Microsoft.Management/managementGroups/slcorp-corp" If I understand correctly how it is supposed to work, the first one should not be granted on the slcorp-corp management group, but rather on the slcorp-connectivity as depicted in this blog entry. I am having difficulty to find where the role assignments is defined, I will look further if I have time! |
@steph409 Can you confirm you are using module 1.4 and not module 4.2? |
sorry it's 4.2.0! |
I have solved this issue by the following code for the latest release of the module.
|
I'm also getting a similar error when creating a private AKS cluster Can this be solved using the module instead of implementing the workaround? |
Not sure why this has been set back to Needs Author Feedback, because the original submitter confirmed they were using 4.2.0 not 1.4.0. This is still an issue with the 5.x releases, and I'm using the workaround detailed by hlokensgard. To answer steph409's question about how where the role assignments come from, I believe for the policy set they are the set of the I think there's an ability to specify a custom role assignment to the policy assignment, but I haven't looked into it in detail. |
Hi, @matt-FFFFFF do you know how this is solved in bicep/portal landing zone? they must have the same issue, would be interesting to know if they have solved this by adding the permission in the module. What we need in the module is something like this: # if there is a connectivity management group, and there is a policy assignment for private dns zones,
# # then we need this additional permission for the policy to function correctly
resource "azurerm_role_assignment" "fix_dns_automation" {
for_each = { for idx, v in azurerm_management_group_policy_assignment.enterprise_scale : idx => v if strcontains(idx, "Deploy-Private-DNS") }
role_definition_name = "Private DNS Zone Contributor"
scope = "/providers/Microsoft.Management/managementGroups/${var.root_id}-connectivity"
principal_id = each.value.identity[0].principal_id
} alternatively, we could set the scope of the role assignment to the connectivity subscription if one is provided: resource "azurerm_role_assignment" "fix_dns_automation" {
for_each = { for idx, v in azurerm_management_group_policy_assignment.enterprise_scale : idx => v
if strcontains(idx, "Deploy-Private-DNS") && var.subscription_id_connectivity != "" }
role_definition_name = "Private DNS Zone Contributor"
scope = "/subscriptions/${var.subscription_id_connectivity}"
principal_id = each.value.identity[0].principal_id
} happy to discuss it! |
It's best practice to perform the role assignment at the resource level. This is what the portal does when you manually assign a policy. It uses the Bicep has a list of well role assignments and they create the role assignment manually. In the new version of the ALZ Terraform module/provider we are able to detect this property and perform the role assignments programmatically. With this module we could use a method similar to the one you suggest above. |
Co-authored-by: github-actions <[email protected]>
* feat(connectivity): Add option to set allow_non_virtual_wan_traffic in express route gateway. (Azure#914) Co-authored-by: Miltos Tsatsakis <[email protected]> * updates to resolve issue Azure#794 (Azure#919) Co-authored-by: github-actions <[email protected]> * docs: update docs for threat_intelligence_allowlist (Azure#928) * Update wiki-sync.yml * chore(deps): bump github/super-linter from 5 to 6 (Azure#931) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * add link to Upgrade guide from v4.2.0 to v5.0.0 (Azure#934) Co-authored-by: Matt White <[email protected]> * Added hub_routing_preference to connectivity advanced configuration (Azure#930) * Policy sync updates (Azure#959) * Update Library Templates (automated) (Azure#966) Co-authored-by: github-actions <[email protected]> * Add remote branch option (Azure#970) * Update Library Templates (automated) (Azure#973) Co-authored-by: github-actions <[email protected]> * Update Library Templates (automated) (Azure#976) Co-authored-by: github-actions <[email protected]> * Remove redundant assignment file (Azure#977) * updating threat intelligence allowlist dynamic block (Azure#953) Co-authored-by: Matt White <[email protected]> * chore(deps): bump azure/powershell from 1 to 2 (Azure#917) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add OpenSFF Scorecard (Azure#987) * chore(deps): bump github/codeql-action from 3.24.9 to 3.25.8 (Azure#990) * chore(deps): bump github.com/hashicorp/go-getter from 1.7.3 to 1.7.4 in /tests/terratest (Azure#986) * feat!: ama (Azure#968) * Fix example uami issue (Azure#1000) * Update Library Templates (automated) (Azure#1001) Co-authored-by: github-actions <[email protected]> * docs: additional v6 upgrade detail (Azure#1002) * Update Library Templates (automated) (Azure#1006) Co-authored-by: github-actions <[email protected]> * docs: update docs with FAQ on roadmap and banner for upcoming breaking changes (Azure#1008) * naming fixed in module --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Mtsa <[email protected]> Co-authored-by: Miltos Tsatsakis <[email protected]> Co-authored-by: Adam Tuckwell <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Jared Holgate <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tobias <[email protected]> Co-authored-by: Matt White <[email protected]> Co-authored-by: QBY-MarkusMaring <[email protected]> Co-authored-by: cae-pr-creator[bot] <126156663+cae-pr-creator[bot]@users.noreply.github.com> Co-authored-by: Daan Toes <[email protected]>
Community Note
Versions
terraform: 1.5.1
azure provider: 3.3.5
module: 1.4.0
Description
Describe the bug
Policy: Deploy-Private-DNS-Zones
There is a build-in policy on the corp-landing-zones management group. It creates an A record in the private DNS zone in the connectivity subscription.
In order to create the A record, the managed identity seems to need two permissions:
corp-landing-zone
, it hasnetwork contributor
andPrivate DNS Zone Contributor
, and this is sufficient to modify the private endpoints within this subscription.connectivity-platform-subscription
, it has no permissions. It seems to need the permissionMicrosoft.Network/privateDnsZones/join/action
to add the A record to the existing private DNS zone. This permission seems to be missing and I do not understand where in the code the permissions to the system assigned identities are managed.Steps to Reproduce
I use the following sample configuration: vwan with custom parameters
where I modified the following lines:
Additional context
For testing, I have an azure container registry with a private endpoint, lacking a private dns entry. The policy successfully shows, that the a record is missing in the central DNS. When I trigger a remediation task, I get the following error message:
The subscription id starting with b74 is the corp-landing zone, the one with 99d is the connectivity one. The client-id ebd.. is the enterprise application for the policy
Deploy-Private-DNS-Zones
.I validated the scopes and the scope and this is exactly where the private dns zone is.
Happy to give further details if this helps.
The text was updated successfully, but these errors were encountered: