<p>I'm creating three EKS clusters using <a href="https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest" rel="nofollow noreferrer">this</a> module. Everything works fine, just that when I try to add the configmap to the clusters using <code>map_roles</code>, I face an issue.</p>
<p>My configuration looks like this which I have it within all three clusters</p>
<pre><code>map_roles = [{
    rolearn   = &quot;arn:aws:iam::${var.account_no}:role/argo-${var.environment}-${var.aws_region}&quot;
    username  = &quot;system:node:{{EC2PrivateDNSName}}&quot;
    groups    = [&quot;system:bootstrappers&quot;,&quot;system:nodes&quot;]
    },
    {
    rolearn   = &quot;arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_1}&quot;
    username  = &quot;admin&quot;
    groups    = [&quot;system:masters&quot;,&quot;system:nodes&quot;,&quot;system:bootstrappers&quot;]
    },
    {
    rolearn  = &quot;arn:aws:sts::${var.account_no}:assumed-role/${var.assumed_role_2}&quot;
    username  = &quot;admin&quot;
    groups    = [&quot;system:masters&quot;,&quot;system:nodes&quot;,&quot;system:bootstrappers&quot;]
    }
]
</code></pre>
<p>The problem occurs while applying the template. It says</p>
<pre><code>configmaps &quot;aws-auth&quot; already exists
</code></pre>
<p>When I studied the error further I realised that when applying the template, the module creates three configmap resources of the same name like these</p>
<pre><code> resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; {
   # ...
 }
 resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; {
   # ...
 }
 resource &quot;kubernetes_config_map&quot; &quot;aws_auth&quot; {
   # ...
 }
</code></pre>
<p>This obviously is a problem. How do I fix this issue?</p>

Red Bottle
<p>I know that it's too late. But sharing a solution that I found.</p>
<p>We should use <strong>kubernetes_config_map_v1_data</strong> instead of <em><strong>kubernetes_config_map_v1</strong></em>. This resource allows Terraform to manage data within a pre-existing ConfigMap.</p>
<p>Example,</p>
<pre><code>resource &quot;kubernetes_config_map_v1_data&quot; &quot;aws_auth&quot; {
  metadata {
    name      = &quot;aws-auth&quot;
    namespace = &quot;kube-system&quot;
  }

  data = {
    &quot;mapRoles&quot; = data.template_file.aws_auth_template.rendered
  }

  force = true
}



data &quot;template_file&quot; &quot;aws_auth_template&quot; {
    template = &quot;${file(&quot;${path.module}/aws-auth-template.yml&quot;)}&quot;
    vars = {
        cluster_admin_arn = &quot;${local.accounts[&quot;${var.env}&quot;].cluster_admin_arn}&quot;
    }
}
</code></pre>
