<p>I used the Terraform module <a href="https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest" rel="nofollow noreferrer">here</a> to create an AWS EKS kubernetes cluster.</p>
<p>How can i add a key pair to the EC2 instance that'll be used for the worker &amp; master nodes?</p>
<p>The reason for this is to be able to SSH into the node directly using the key pair.
If i don't use this approach of adding a key pair, how else can i SSH into the node itself from my local machine?</p>
<p>What i thought of using is: <code>cluster_ca_certificate</code> but I'm not sure if this will work, or how to use it.</p>

james
<p>You need to add this block to your terraform code:</p>
<pre><code>  worker_groups_launch_template = [
    {
      name                  = &quot;on-demand&quot;
      key_name              = &quot;key-name-must-exist&quot;
      instance_type         = &quot;t3a.xlarge&quot;
      asg_min_size          = 1
      asg_desired_capacity  = 1
      asg_max_size          = 5
      autoscaling_enabled   = true
      asg_force_delete      = true
      enable_monitoring     = false
      enabled_metrics       = [&quot;GroupMinSize&quot;, &quot;GroupMaxSize&quot;, &quot;GroupDesiredCapacity&quot;]
      kubelet_extra_args    = &quot;&quot;
      additional_userdata   = &quot;&quot;
      suspended_processes   = [&quot;AZRebalance&quot;]
      subnets               = private_subnets
      tags = [
        {
          &quot;key&quot;                 = &quot;k8s.io/cluster-autoscaler/enabled&quot;
          &quot;propagate_at_launch&quot; = &quot;false&quot;
          &quot;value&quot;               = &quot;true&quot;
        },
        {
          &quot;key&quot;                 = &quot;k8s.io/cluster-autoscaler/clustername&quot;
          &quot;propagate_at_launch&quot; = &quot;false&quot;
          &quot;value&quot;               = &quot;true&quot;
        }
      ]
    }
  ]    
</code></pre>
<p>Remember to change the key_name to match with your ssh key and edit the SG of nodes so that it can receive traffic directly from your local machine</p>
