I want to create a new node group with a specific Auto scaling group and launch template I am creating.
When running the following TF file:
resource "aws_launch_template" "jupyter-gpu-stage" {
block_device_mappings {
device_name = "/dev/xvda"
ebs {
volume_size = 100
volume_type = "gp2"
delete_on_termination = "true"
}
}
name_prefix = "jupyter-gpu-stage-"
image_id = "ami-123456789"
instance_type = "g4dn.2xlarge"
network_interfaces {
security_groups = [module.aws_eks.node_security_group_id]
}
}
resource "aws_autoscaling_group" "jupyter-stage-gpu" {
depends_on = [aws_launch_template.jupyter-gpu-stage]
name_prefix = "eks-jupyter-stage-gpu-"
max_size = 100
min_size = 0
desired_capacity = 0
vpc_zone_identifier = var.subnet_ids # Specify your subnet IDs here
launch_template {
id = aws_launch_template.jupyter-gpu-stage.id
version = aws_launch_template.jupyter-gpu-stage.latest_version
}
}
resource "aws_eks_node_group" "jupyter-stage-gpu" {
cluster_name = module.aws_eks.cluster_name
node_role_arn = module.aws_eks.eks_managed_node_groups["main"].iam_role_arn
subnet_ids = var.subnet_ids
# Optional
node_group_name_prefix = "jupyter-stage-gpu-"
scaling_config {
desired_size = 0
max_size = 100
min_size = 0
}
launch_template {
id = aws_launch_template.jupyter-gpu-stage.id
version = aws_launch_template.jupyter-gpu-stage.latest_version
}
}
AWS still creates its own ASG and Launch Template. How can I disable such behavior? I want the node group to use the specific ASG and Launch Template
To whoever is looking for a solution to the same problem, I found the issue. The launch template was missing user_data information. I passed it like this:
user_data = filebase64("${path.module}/user_data.sh")