-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathservice-account.tf
34 lines (29 loc) · 1.08 KB
/
service-account.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
locals {
create_namespace_via_this_module = var.create_kubernetes_namespace && var.namespace != "kube-system" && var.namespace != "default" ? 1 : 0
}
resource "kubernetes_namespace_v1" "this" {
count = local.create_namespace_via_this_module
metadata {
labels = var.namespace_labels
name = var.namespace
annotations = var.namespace_annotations
}
timeouts {
delete = "15m"
}
}
resource "kubernetes_service_account_v1" "this" {
count = var.create_service_account ? 1 : 0
automount_service_account_token = var.automount_service_account_token
metadata {
name = var.service_account_name
namespace = var.namespace
annotations = merge(
{
"azure.workload.identity/client-id" = azurerm_user_assigned_identity.this.client_id
"azure.workload.identity/tenant-id" = data.azurerm_client_config.current.tenant_id
"azure.workload.identity/service-account-token-expiration" = var.service_account_token_expiration_seconds
}
, var.additional_service_account_annotations)
}
}