<p>How can I see which instances are associated with an EKS cluster?</p>

<p>I can use the AWS CLI to list cluster names and describe clusters, but how can I see which instances are actually in the cluster?</p>

<p><code>aws eks list-clusters --region us-east-1</code></p>

<pre><code>    "clusters": [
        "foo-cluster",
        "bar-cluster"
    ]
}
</code></pre>

<p><code>aws eks describe-cluster --name foo-cluster</code></p>

<pre><code>{
    "cluster": {
        "name": "foo-cluster",
        "arn": "arn:aws:eks:us-east-1:12345:cluster/foo-cluster",
        "createdAt": 1554068824.493,
        "version": "1.13",
        "endpoint": "https://12345.abc.us-east-1.eks.amazonaws.com",
        "roleArn": "arn:aws:iam::12345:role/foo-cluster12345",
        "resourcesVpcConfig": {
            "subnetIds": [
                "subnet-45678",
                "subnet-34567",
                "subnet-23456",
                "subnet-12345"
            ],
            "securityGroupIds": [
                "sg-12345"
            ],
            "vpcId": "vpc-12345"
        },
        "status": "ACTIVE",
        "certificateAuthority": {
            "data": "zubzubzub="
        },
        "platformVersion": "eks.2"
    }
}

</code></pre>

jjones
<p>You can't from the <code>aws eks ...</code> CLI specifically. Kubernetes nodes are basically EC2 instances, so hopefully, you tagged your instances appropriately when you created them, typically with an Autoscaling Group with a tool like <a href="https://docs.aws.amazon.com/eks/latest/userguide/launch-workers.html" rel="noreferrer">eksctl</a>. </p>

<p>Your instances typically will have a 'Name' tag that is the same as the worker node name. So you could do:</p>

<pre><code>$ aws ec2 describe-instances --filters Name=tag:Name,Values=node-name
</code></pre>

<p>Alternatively, you can get either the <code>NAME</code> or the <code>INTERNAL-IP</code> of the node with:</p>

<pre><code>$ kubectl get nodes -o=wide
</code></pre>

<p>Then you can find your instances based on that:</p>

<pre><code>$ aws ec2 describe-instances --filter Name=private-dns-name,Values=NAME
$ aws ec2 describe-instances --filter Name=private-ip-address,Values=INTERNAL-IP
</code></pre>

<p>Alternative, you can query the autoscaling group:</p>

<pre><code>$ aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names &lt;your-asg-name&gt; | jq .AutoScalingGroups[0].Instances[].InstanceId
</code></pre>
