<p>I am deploying AWS EKS Cluster using a terraform script. Everything is deploying fine. 
But I am stuck in an issue with the security group. I have added two ports to allow ingress traffic to my application URL. </p>

<p>But the issue is that, after complete deployment of EKS cluster there is two security group created, one which I have created and other is created by EKS itself. </p>

<p>So here I have to manually add the port in EKS created security group to access my application's URL on the browser. </p>

<p>Here how I can add my specific ports in EKS created security group.</p>

Albus
<p>Here is the appropriate answer. If you scroll down the page in the terraform docs, it gives a list of attributes (which are exportable): <a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster" rel="nofollow noreferrer">https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster</a>. You will notice vpc_config attributes has a member cluster_security_group_id:</p>
<blockquote>
<p>vpc_config Attributes cluster_security_group_id - Cluster security
group that was created by Amazon EKS for the cluster. Managed node
groups use this security group for control-plane-to-data-plane
communication.</p>
</blockquote>
<p>To actually gain access to this property, given that vpc_config is a list, you will need to access it as so:</p>
<pre><code> aws_eks_cluster.cluster.vpc_config[0].cluster_security_group_id
</code></pre>
<p>If you do not specify a cluster security group, then AWS will autogenerate a cluster security group which contains the rules to allow the cluster and the cluster node group to communicate. Consequently, it is a common pattern to export this property like so:</p>
<pre><code>output &quot;cluster_security_group_id&quot; {
    value   = aws_eks_cluster.cluster.vpc_config[0].cluster_security_group_id
}
</code></pre>
