resource "aws_launch_template" "lcsp-use1-eks-launch-template" {
  # checkov:skip=CKV_AWS_126:Ensure that detailed monitoring is enabled for EC2 instances
  # checkov:skip=CKV_AWS_135:Ensure that EC2 is EBS optimized
  # checkov:skip=CKV_AWS_79:Ensure Instance Metadata Service Version 1 is not enabled
  # checkov:skip=CKV_AWS_8:Ensure all data stored in the Launch configuration EBS is securely encrypted
  name                   = "lcsp-use1-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.GRPS-P1-EKS-Worker-SG.id]
  user_data              = base64encode(templatefile("${path.module}/userdata-scripts/userdata.tpl", { CLUSTER_NAME = aws_eks_cluster.sme-label-copy-schedule-prod-use1-cluster-01.name, B64_CLUSTER_CA = aws_eks_cluster.sme-label-copy-schedule-prod-use1-cluster-01.certificate_authority[0].data, API_SERVER_URL = aws_eks_cluster.sme-label-copy-schedule-prod-use1-cluster-01.endpoint }))
  tags                   = var.tags
  tag_specifications {
    resource_type = "instance"
    tags          = merge(var.tags, { Name = "sme-label-copy-schedule-prod-use1-cluster-01-worker-node" })
  }
}