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