Skip to content

Commit

Permalink
yaml mangling
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Jan 13, 2025
1 parent 85154e1 commit 926daa2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions eks_console_access.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,24 @@ data "http" "cluster_roles" {
# }

# # Apply the Kubernetes manifests to the cluster
# resource "kubernetes_manifest" "deploy_cluster_roles" {
# # depends_on = [null_resource.cluster_roles]
# for_each = { for k, v in local.cluster_roles_map : k => v if v.enabled }
# manifest = [yamldecode(data.http.cluster_roles[each.key].body)]
# }

resource "kubernetes_manifest" "deploy_cluster_roles" {
# depends_on = [null_resource.cluster_roles]
for_each = { for k, v in local.cluster_roles_map : k => v if v.enabled }
manifest = [yamldecode(data.http.cluster_roles[each.key].body)]
for_each = {
for value in [
for yaml in split(
"\n---\n",
"\n${replace(data.http.cluster_roles[each.key].body, "/(?m)^---[[:blank:]]*(#.*)?$/", "---")}\n"
) :
yamldecode(yaml)
if trimspace(replace(yaml, "/(?m)(^[[:blank:]]*(#.*)?$)+/", "")) != ""
] : "${value["kind"]}--${value["metadata"]["name"]}" => value
}
manifest = each.value
}

# resource "null_resource" "apply_cluster_roles" {
Expand Down

0 comments on commit 926daa2

Please sign in to comment.