Azure resources¶
The generated terraform/main.tf creates two user-assigned managed identities,
a federated identity credential for each, and four role assignments. It creates
no container registry and no storage account: those are yours, named in the
install spec, and Terraform assigns roles on them.
What it renders¶
terraform {
required_providers {
azurerm = { source = "hashicorp/azurerm", version = "~> 4.0" }
}
}
provider "azurerm" {
features {}
subscription_id = "<subscription-id>"
tenant_id = "<tenant-id>"
}
resource "azurerm_user_assigned_identity" "runtime" {
name = "dp-eu-west1-runtime"
location = "<location>"
resource_group_name = "<resource-group>"
}
resource "azurerm_user_assigned_identity" "build" {
name = "dp-eu-west1-build"
location = "<location>"
resource_group_name = "<resource-group>"
}
Then the federation, one per Kubernetes service account:
resource "azurerm_federated_identity_credential" "runtime" {
name = "xratu-runtime-fic"
resource_group_name = "<resource-group>"
parent_id = azurerm_user_assigned_identity.runtime.id
audience = ["api://AzureADTokenExchange"]
issuer = "https://<location>.oic.prod-aks.azure.com/<aks-oidc-path>/"
subject = "system:serviceaccount:dp-eu-west1:xratud"
}
Then the role assignments:
resource "azurerm_role_assignment" "runtime_acr_push" {
scope = "/subscriptions/.../resourceGroups/<resource-group>/providers/Microsoft.ContainerRegistry/registries/<acr-name>"
role_definition_name = "AcrPush"
principal_id = azurerm_user_assigned_identity.runtime.principal_id
}
resource "azurerm_role_assignment" "runtime_bucket_blob_data_contributor" {
scope = "/subscriptions/.../providers/Microsoft.Storage/storageAccounts/<storage-account>/blobServices/default/containers/<container>"
role_definition_name = "Storage Blob Data Contributor"
principal_id = azurerm_user_assigned_identity.runtime.principal_id
}
Build gets the same two assignments.
The two identities¶
| Identity | Name | Federated to |
|---|---|---|
| Runtime | dp-eu-west1-runtime |
system:serviceaccount:dp-eu-west1:xratud |
| Build | dp-eu-west1-build |
system:serviceaccount:xratu-build-bootstrap:builder |
The subject on each federated credential pins it to exactly one Kubernetes
service account, the same way AWS pins its trust policy condition.
What you bring¶
| Resource | Created by |
|---|---|
| The subscription and resource group | You |
| The AKS cluster, with OIDC issuer and workload identity enabled | You |
| The container registry | You |
| The storage account and container | You |
| Managed identities, federation and role assignments | This Terraform |
The value Terraform produces that the cluster needs¶
Each managed identity has a client ID that exists only after terraform apply.
The service account manifests are rendered before that, so they carry
placeholders. See
Azure workload identity.