Skip to content

Instantly share code, notes, and snippets.

@raykao
Created January 13, 2023 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raykao/814a4aa9fa47bd247c37f1d2adfd1255 to your computer and use it in GitHub Desktop.
Save raykao/814a4aa9fa47bd247c37f1d2adfd1255 to your computer and use it in GitHub Desktop.
resource "azurerm_user_assigned_identity" "cluster" {
location = azurerm_resource_group.example.location
name = "aks-cluster-identity-${var.cluster_uid}"
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_user_assigned_identity" "kubelet" {
location = azurerm_resource_group.example.location
name = "aks-kubelet-identity-${var.cluster_uid}"
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_role_definition" "cluster-identity" {
role_definition_id = "00000000-0000-0000-0000-000000000000"
name = "aks-cluster-identity"
scope = ***Azure Resource ID e.g. RG/Storage/Compute***
permissions {
actions = ["Microsoft.Resources/subscriptions/resourceGroups/read"]
not_actions = []
}
assignable_scopes = [
***Same as above***,
]
}
resource "azurerm_role_assignment" "cluster-identity" {
name = "00000000-0000-0000-0000-000000000000"
scope = ***your azure resource uuid***
role_definition_id = azurerm_role_definition.cluster-identity.role_definition_resource_id
principal_id = azurerm_user_assigned_identity.cluster.object_id
}
resource "azurerm_role_definition" "kubelet-identity" {
role_definition_id = "00000000-0000-0000-0000-000000000000"
name = "aks-kubelet-identity"
scope = ***Azure Resource ID e.g. RG/Storage/Compute***
permissions {
actions = ["Microsoft.Resources/subscriptions/resourceGroups/read"]
not_actions = []
}
assignable_scopes = [
***Same as above***,
]
}
resource "azurerm_role_assignment" "kubelet-identity" {
name = "00000000-0000-0000-0000-000000000000"
scope = ***your azure resource uuid***
role_definition_id = azurerm_role_definition.kubelet-identity.role_definition_resource_id
principal_id = azurerm_user_assigned_identity.kubelet.object_id
}
resource "azurerm_kubernetes_cluster" "example" {
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment