main.tf 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. data "azurerm_client_config" "current" {}
  2. data "azurerm_subscription" "primary" {}
  3. module "test_resource_group" {
  4. source = "./resource-group"
  5. resource_group_name = var.resource_group_name
  6. resource_group_location = var.resource_group_location
  7. }
  8. module "test_sp" {
  9. source = "./service-principal"
  10. application_display_name = var.application_display_name
  11. application_owners = [data.azurerm_client_config.current.object_id]
  12. issuer = module.test_aks.cluster_issuer_url
  13. subject = "system:serviceaccount:${var.sa_namespace}:${var.sa_name}"
  14. }
  15. module "test_key_vault" {
  16. source = "./key-vault"
  17. key_vault_display_name = var.key_vault_display_name
  18. resource_group_location = var.resource_group_location
  19. resource_group_name = var.resource_group_name
  20. tenant_id = data.azurerm_client_config.current.tenant_id
  21. client_object_id = data.azurerm_client_config.current.object_id
  22. eso_sp_object_id = module.test_sp.sp_object_id
  23. }
  24. module "test_workload_identity" {
  25. source = "./workload-identity"
  26. tenant_id = data.azurerm_client_config.current.tenant_id
  27. tags = var.cluster_tags
  28. }
  29. module "test_aks" {
  30. source = "./aks"
  31. cluster_name = var.cluster_name
  32. resource_group_name = var.resource_group_name
  33. resource_group_location = var.resource_group_location
  34. default_node_pool_node_count = var.default_node_pool_node_count
  35. default_node_pool_vm_size = var.default_node_pool_vm_size
  36. cluster_tags = var.cluster_tags
  37. }
  38. resource "azurerm_role_assignment" "current" {
  39. scope = data.azurerm_subscription.primary.id
  40. role_definition_name = "Reader"
  41. principal_id = module.test_sp.sp_id
  42. }
  43. resource "kubernetes_service_account" "current" {
  44. metadata {
  45. name = "external-secrets-operator"
  46. namespace = "external-secrets-operator"
  47. annotations = {
  48. "azure.workload.identity/client-id" = module.test_sp.application_id
  49. "azure.workload.identity/tenant-id" = data.azurerm_client_config.current.tenant_id
  50. }
  51. labels = {
  52. "azure.workload.identity/use" = "true"
  53. }
  54. }
  55. }