From 70c4768538879ab9f2444a6eaec7b40ab2e7cc61 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 11 Sep 2025 13:01:38 -0400 Subject: [PATCH] Refactor repository and cluster configuration: unify naming and update descriptions in main.tf and variables.tf --- examples/basic/main.tf | 3 +- examples/centralized-management/main.tf | 56 +++++++++---------------- main.tf | 6 +-- variables.tf | 3 +- 4 files changed, 25 insertions(+), 43 deletions(-) diff --git a/examples/basic/main.tf b/examples/basic/main.tf index 76c0e02..d84fb0b 100644 --- a/examples/basic/main.tf +++ b/examples/basic/main.tf @@ -12,7 +12,7 @@ provider "github" { module "eks_deployment" { source = "../../" - # Repository configuration + # Repository and cluster configuration - single name for both name = "eks-test-cluster" template_repo_org = "SCT-Engineering" repository_template = "template-eks-cluster" @@ -37,7 +37,6 @@ module "eks_deployment" { aws_profile = "default" vpc_name = "vpc3-csvd-dev" vpc_domain_name = "dev.inf.csp1.census.gov" - cluster_name = "dev-eks-01" cluster_mailing_list = "david.j.arnold.jr@census.gov" eks_instance_disk_size = 100 eks_ng_desired_size = 3 diff --git a/examples/centralized-management/main.tf b/examples/centralized-management/main.tf index 014e335..5e09a13 100644 --- a/examples/centralized-management/main.tf +++ b/examples/centralized-management/main.tf @@ -16,10 +16,10 @@ provider "github" { module "prod_eks_cluster" { source = "../../" - # Repository configuration - repository_name = "eks-prod-cluster" - repository_template_owner = "HappyPathway" - repository_template = "template-eks-cluster" + # Repository and cluster configuration - single name for both + name = "eks-prod-cluster" # This name is used for both the repository and cluster + template_repo_org = "HappyPathway" + repository_template = "template-eks-cluster" repository_teams = { "platform-team" = "admin", "prod-sre-team" = "maintain", @@ -32,22 +32,14 @@ module "prod_eks_cluster" { region = "us-gov-west-1" github_server_url = var.github_server_url - # Account configuration - account_config = { - account_name = "prod-account" - aws_account_id = var.prod_account_id - environment_abbr = "prod" - } - - # VPC configuration - vpc_config = { - vpc_name = "prod-vpc" - vpc_domain_name = "prod.example.com" - } - # Cluster configuration cluster_config = { - cluster_name = "prod-eks-01" + account_name = "prod-account" + aws_account_id = var.prod_account_id + environment_abbr = "prod" + aws_profile = "default" + vpc_name = "prod-vpc" + vpc_domain_name = "prod.example.com" cluster_mailing_list = "prod-alerts@example.com" eks_instance_disk_size = 200 eks_ng_desired_size = 5 @@ -75,10 +67,10 @@ module "prod_eks_cluster" { module "dev_eks_cluster" { source = "../../" - # Repository configuration - repository_name = "eks-dev-cluster" - repository_template_owner = "HappyPathway" - repository_template = "template-eks-cluster" + # Repository and cluster configuration - single name for both + name = "eks-dev-cluster" # This name is used for both the repository and cluster + template_repo_org = "HappyPathway" + repository_template = "template-eks-cluster" repository_teams = { "platform-team" = "admin", "dev-team" = "maintain", @@ -91,22 +83,14 @@ module "dev_eks_cluster" { region = "us-gov-west-1" github_server_url = var.github_server_url - # Account configuration - account_config = { - account_name = "dev-account" - aws_account_id = var.dev_account_id - environment_abbr = "dev" - } - - # VPC configuration - vpc_config = { - vpc_name = "dev-vpc" - vpc_domain_name = "dev.example.com" - } - # Cluster configuration cluster_config = { - cluster_name = "dev-eks-01" + account_name = "dev-account" + aws_account_id = var.dev_account_id + environment_abbr = "dev" + aws_profile = "default" + vpc_name = "dev-vpc" + vpc_domain_name = "dev.example.com" cluster_mailing_list = "dev-alerts@example.com" eks_instance_disk_size = 100 eks_ng_desired_size = 2 diff --git a/main.tf b/main.tf index 60094d7..af88a2b 100644 --- a/main.tf +++ b/main.tf @@ -20,7 +20,7 @@ locals { aws_region = var.region }), "environment/region/vpc/cluster/cluster.hcl" : templatefile("${path.module}/templates/cluster.hcl.tf.tpl", { - cluster_name = var.cluster_config.cluster_name, + cluster_name = var.name, cluster_mailing_list = var.cluster_config.cluster_mailing_list, eks_instance_disk_size = var.cluster_config.eks_instance_disk_size, eks_ng_desired_size = var.cluster_config.eks_ng_desired_size, @@ -35,7 +35,7 @@ locals { }), "README.md" : templatefile("${path.module}/templates/README.md.tf.tpl", { environment = var.environment, - cluster_name = var.cluster_config.cluster_name, + cluster_name = var.name, aws_region = var.region }) } @@ -46,7 +46,7 @@ module "github_repo" { name = var.name repo_org = var.organization - github_repo_description = "EKS Cluster Configuration for ${var.cluster_config.cluster_name}" + github_repo_description = "EKS Cluster Configuration for ${var.name}" github_repo_topics = ["eks", "kubernetes", "terraform", "infrastructure"] force_name = var.force_name diff --git a/variables.tf b/variables.tf index 6ef71b2..bbe40c8 100644 --- a/variables.tf +++ b/variables.tf @@ -1,5 +1,5 @@ variable "name" { - description = "The name of the repository." + description = "The name of the repository and EKS cluster. This name will be used for both the GitHub repository and the EKS cluster." type = string } @@ -165,7 +165,6 @@ variable "namespaces" { variable "cluster_config" { description = "Configuration for the EKS cluster" type = object({ - cluster_name = string account_name = string aws_account_id = string aws_profile = string