Skip to content

Commit

Permalink
update to track files in template-eks-cluster/
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Mar 17, 2026
1 parent 58fe8cd commit f6d60ee
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
locals {
template_cluster_sync_files = [
for rel_path in var.template_cluster_file_paths : {
path = "${var.environment}/${var.region}/vpc/cluster/${rel_path}"
content = data.github_repository_file.template_cluster_files[rel_path].content
}
if lookup(var.template_enabled_modules, split(rel_path, "/")[0], false)
]

managed_extra_files = concat([
{
path = "_envcommon/default-versions.hcl"
Expand Down Expand Up @@ -89,6 +97,14 @@ data "github_repository" "existing_repo" {
full_name = "${var.organization}/${var.name}"
}

data "github_repository_file" "template_cluster_files" {
for_each = toset(var.template_cluster_file_paths)

repository = var.template_repo_name
branch = var.template_repo_ref
file = "environment/region/vpc/cluster/${each.value}"
}

resource "github_branch" "files_branch" {
count = !var.create_repository && var.files_branch != null ? 1 : 0
repository = data.github_repository.existing_repo[0].name
Expand Down Expand Up @@ -122,6 +138,7 @@ module "github_repo" {
path = path
content = content
}],
local.template_cluster_sync_files,
local.managed_extra_files,
var.github_actions_workflows)

Expand Down
59 changes: 59 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,63 @@ variable "files_branch_source_branch" {
description = "Source branch used when creating files_branch for existing repositories. Defaults to the repository default branch."
type = string
default = null
}

variable "template_repo_name" {
description = "Name of the template repository used as authoritative source for cluster-level terragrunt files."
type = string
default = "template-eks-cluster"
}

variable "template_repo_ref" {
description = "Branch, tag, or SHA to read from template_repo_name when syncing cluster-level terragrunt files."
type = string
default = "main"
}

variable "template_cluster_file_paths" {
description = "List of file paths under environment/region/vpc/cluster in template_repo_name to sync into environment/region-resolved cluster path."
type = list(string)
default = [
"eks/terragrunt.hcl",
"eks-config/terragrunt.hcl",
"eks-cribl/terragrunt.hcl",
"eks-dns/terragrunt.hcl",
"eks-gatekeeper/terragrunt.hcl",
"eks-grafana/terragrunt.hcl",
"eks-istio/terragrunt.hcl",
"eks-karpenter/terragrunt.hcl",
"eks-keycloak/terragrunt.hcl",
"eks-kiali/terragrunt.hcl",
"eks-loki/terragrunt.hcl",
"eks-otel/terragrunt.hcl",
"eks-prometheus/terragrunt.hcl",
"eks-tempo/terragrunt.hcl",
]
}

variable "template_enabled_modules" {
description = "Enablement map used to decide which template_cluster_file_paths are synced. Key must match the first path segment, for example eks-grafana in eks-grafana/terragrunt.hcl."
type = map(bool)
default = {
eks = true
eks-config = true
eks-dns = true
eks-istio = true
eks-karpenter = true
eks-arcgis = false
eks-cribl = false
eks-gatekeeper = true
eks-grafana = true
eks-keycloak = true
eks-kiali = true
eks-loki = true
eks-otel = true
eks-pipeline = false
eks-postgresql = false
eks-prometheus = true
eks-tempo = true
eks-cert-manager = false
eks-k8s-dashboard = false
}
}

0 comments on commit f6d60ee

Please sign in to comment.