Skip to content

Commit

Permalink
Cleanup node group if build node is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
nightfury1204 committed May 31, 2023
1 parent 5d2a118 commit 6df011a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion terraform/cluster/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ resource "aws_eks_node_group" "cluster-build" {
aws_iam_openid_connect_provider.cluster,
]

count = 1
count = var.build_node_enabled ? 1 : 0

ami_type = var.gpu_type ? "AL2_x86_64_GPU" : var.arm_type ? "AL2_ARM_64" : "AL2_x86_64"
capacity_type = "ON_DEMAND"
Expand Down Expand Up @@ -169,6 +169,8 @@ resource "aws_autoscaling_group_tag" "cluster-build" {
aws_eks_node_group.cluster-build
]

count = var.build_node_enabled ? 1 : 0

autoscaling_group_name = aws_eks_node_group.cluster-build[0].resources[0].autoscaling_groups[0].name

tag {
Expand Down
4 changes: 4 additions & 0 deletions terraform/cluster/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ variable "availability_zones" {
default = ""
}

variable "build_node_enabled" {
default = false
type = bool
}

variable "build_node_type" {
type = string
Expand Down
1 change: 1 addition & 0 deletions terraform/system/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module "cluster" {
arm_type = local.arm_type
availability_zones = var.availability_zones
build_node_enabled = var.build_node_enabled
build_node_min_count = var.build_node_min_count
build_node_type = var.build_node_type != "" ? var.build_node_type : var.node_type
cidr = var.cidr
Expand Down

0 comments on commit 6df011a

Please sign in to comment.