resource "aws_launch_template" "amp-prod-as-eks-launch-template" {
  #checkov:skip=CKV_AWS_79: Ensure Instance Metadata Service Version 1 is not enabled. Migrated existing infrastructure as-is; IMDS settings managed outside this config.
  name                   = "amp-prod-as-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.AMPP-EKS-Worker-SG.id]
  user_data              = base64encode(templatefile("${path.module}/userdata-scripts/userdata.tpl", { CLUSTER_NAME = aws_eks_cluster.amp-prod-as-eks.name, B64_CLUSTER_CA = aws_eks_cluster.amp-prod-as-eks.certificate_authority[0].data, API_SERVER_URL = aws_eks_cluster.amp-prod-as-eks.endpoint }))
  tags                   = var.tags
  tag_specifications {
    resource_type = "instance"
    tags          = merge(var.tags, { Name = "amp-prod-as-eks-worker-nodes" })
  }
}