resource "aws_launch_template" "digsysd3-eks-launch-template" {
  #checkov:skip=CKV_AWS_79: Ensure Instance Metadata Service Version 1 is not enabled
  name                   = "digsysd3-eks-launch-template"
  image_id               = var.launch_template_image_id
  instance_type          = var.launch_template_instance_type
  key_name               = var.launch_template_key_name
  vpc_security_group_ids = [aws_security_group.DIGSYS-D3-EKS-Worker-Node-SG.id]
  user_data              = base64encode(templatefile("${path.module}/userdata-scripts/userdata.tpl", { CLUSTER_NAME = aws_eks_cluster.digsysd3-eks.name, B64_CLUSTER_CA = aws_eks_cluster.digsysd3-eks.certificate_authority[0].data, API_SERVER_URL = aws_eks_cluster.digsysd3-eks.endpoint }))
  tags                   = var.tags
  tag_specifications {
    resource_type = "instance"
    tags          = merge(var.tags, { Name = "digsysd3-eks-worker-nodes" })
  }
}
