Skip to content

Commit

Permalink
enha: added multiple variables for more configuration capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
kfc-manager committed Apr 4, 2024
1 parent a2397ae commit 6dc2b6f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
9 changes: 6 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ resource "aws_iam_role_policy_attachment" "xray" {
################################

resource "aws_eks_cluster" "main" {
name = var.identifier
role_arn = aws_iam_role.master.arn
name = var.identifier
version = var.version
role_arn = aws_iam_role.master.arn
enabled_cluster_log_types = ["api", "audit", "authenticator", "controllerManager", "scheduler"]

vpc_config {
subnet_ids = var.subnets
subnet_ids = var.subnets
security_group_ids = var.security_groups
}

tags = var.tags
Expand Down
20 changes: 18 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ variable "identifier" {
}
}

variable "version" {
description = "The Kubernetes version the cluster runs on."
type = string
default = "1.29"
}

variable "vpc" {
description = "ID of the subnets' VPC."
type = string
Expand All @@ -20,15 +26,25 @@ variable "subnets" {
description = "A list of IDs of subnets for the subnet group and potentially the RDS proxy."
type = list(string)
validation {
condition = length(var.subnets) > 1
error_message = "List of subnets must contain at least 2 elements"
condition = length(var.subnets) > 0
error_message = "List of subnets must contain at least one element"
}
validation {
condition = !contains([for v in var.subnets : startswith(v, "subnet-")], false)
error_message = "Elements must be valid subnet IDs"
}
}

variable "security_groups" {
description = "A list of IDs of subnets for the subnet group and potentially the RDS proxy."
type = list(string)

validation {
condition = !contains([for v in var.subnets : startswith(v, "sg-")], false)
error_message = "Elements must be valid security group IDs"
}
}

variable "disk_size" {
description = "Disk size in GiB of the node group."
type = number
Expand Down

0 comments on commit 6dc2b6f

Please sign in to comment.