Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
saliceti committed Dec 19, 2024
1 parent 440927a commit e862be9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion aks/cluster_data/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ output "ingress_domain" {
}

output "kubelogin_args" {
value = local.spn_authentication ? local.kubelogin_args_map["spn"] : local.kubelogin_args_map["azurecli"]
value = (local.running_in_github_actions ? (
local.spn_secret_authentication ?
local.kubelogin_args_map["spn"] :
local.kubelogin_args_map["workloadidentity"]
) :
local.kubelogin_args_map["azurecli"]
)
}
output "azure_RBAC_enabled" {
value = local.azure_RBAC_enabled
Expand Down
10 changes: 9 additions & 1 deletion aks/cluster_data/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,18 @@ locals {
"azurecli",
"--server-id",
"6dae42f8-4368-4678-94ff-3960e28e3630"
],
workloadidentity = [
"get-token",
"--login",
"workloadidentity",
"--server-id",
"6dae42f8-4368-4678-94ff-3960e28e3630"
]
}

azure_RBAC_enabled = length(data.azurerm_kubernetes_cluster.main.azure_active_directory_role_based_access_control) > 0

spn_authentication = contains(keys(data.environment_variables.github_actions.items), "GITHUB_ACTIONS")
running_in_github_actions = contains(keys(data.environment_variables.github_actions.items), "GITHUB_ACTIONS")
spn_secret_authentication = contains(keys(data.environment_variables.github_actions.items), "AAD_SERVICE_PRINCIPAL_CLIENT_SECRET")
}

0 comments on commit e862be9

Please sign in to comment.