Skip to content

Commit

Permalink
Changed data resource name for aks_node_rg
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrushuk committed Oct 25, 2020
1 parent 0c348da commit f0842c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
4 changes: 4 additions & 0 deletions terraform/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ data "azurerm_subscription" "current" {}
data "azuread_group" "aks" {
name = var.aad_group_name
}

data "azurerm_resource_group" "aks_node_rg" {
name = azurerm_kubernetes_cluster.aks.node_resource_group
}
6 changes: 1 addition & 5 deletions terraform/function_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,8 @@ resource "azurerm_function_app" "func_app" {


# Give Function App Reader role for the AKS cluster node resource group
data "azurerm_resource_group" "aks" {
name = azurerm_kubernetes_cluster.aks.node_resource_group
}

resource "azurerm_role_assignment" "func_app" {
scope = data.azurerm_resource_group.aks.id
scope = data.azurerm_resource_group.aks_node_rg.id
role_definition_name = "Reader"
principal_id = azurerm_function_app.func_app.identity.0.principal_id
}
4 changes: 2 additions & 2 deletions terraform/helm_aad_pod_identity.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ resource "azurerm_role_assignment" "aks_mi_aks_node_rg_vm_contributor" {
count = var.velero_enabled ? 1 : 0
principal_id = azurerm_kubernetes_cluster.aks.kubelet_identity[0].object_id
role_definition_name = "Virtual Machine Contributor"
scope = data.azurerm_resource_group.aks.id
scope = data.azurerm_resource_group.aks_node_rg.id
skip_service_principal_aad_check = true
}

resource "azurerm_role_assignment" "aks_mi_aks_node_rg_mi_operator" {
count = var.velero_enabled ? 1 : 0
principal_id = azurerm_kubernetes_cluster.aks.kubelet_identity[0].object_id
role_definition_name = "Managed Identity Operator"
scope = data.azurerm_resource_group.aks.id
scope = data.azurerm_resource_group.aks_node_rg.id
skip_service_principal_aad_check = true
}

Expand Down
7 changes: 3 additions & 4 deletions terraform/velero_mi_auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ resource "azurerm_role_assignment" "velero_mi_velero_storage_rg" {
scope = azurerm_resource_group.velero[0].id
}

# https://docs.microsoft.com/en-us/azure/role-based-access-control/built-in-roles?source=docs#virtual-machine-contributor
# vm disk read and write action / perms
# assign velero MI contributor rights to velero storage RG
resource "azurerm_role_assignment" "velero_mi_aks_node_rg_vm_contributor" {
count = var.velero_enabled ? 1 : 0
principal_id = azurerm_user_assigned_identity.velero[0].principal_id
role_definition_name = "Virtual Machine Contributor"
scope = data.azurerm_resource_group.aks.id
role_definition_name = "Contributor"
scope = data.azurerm_resource_group.aks_node_rg.id
skip_service_principal_aad_check = true
}

0 comments on commit f0842c4

Please sign in to comment.