<p>I was trying to add permission to view nodes to my admin IAM using information in this article (<a href="https://aws.amazon.com/premiumsupport/knowledge-center/eks-kubernetes-object-access-error/" rel="nofollow noreferrer">https://aws.amazon.com/premiumsupport/knowledge-center/eks-kubernetes-object-access-error/</a>) and ended up saving the configmap with a malformed mapUsers section (didn't include the username at all)</p>
<p>Now every kubectl command return an error like this: Error from server (Forbidden): nodes is forbidden: User &quot;&quot; cannot list resource &quot;nodes&quot; in API group &quot;&quot; at the cluster scope</p>
<p>How can I circumvent corrupted configmap and regain access to the cluster? I found two questions at Stackoverflow but as I am very new to kubernetes and still buffled as to exactly I need to do.</p>
<p><a href="https://stackoverflow.com/questions/59085639/mistakenly-updated-configmap-aws-auth-with-rbac-lost-access-to-the-cluster">Mistakenly updated configmap aws-auth with rbac &amp; lost access to the cluster</a></p>
<p>I have an access to root user but kubectl doesn't work for this user, too.</p>
<p>Is there another way to authenticate to the cluster?</p>
<h2>Update 1</h2>
<p>Yesterday I recreated this problem on a new cluster: I still got this error even if I am the root user.</p>
<p>The structure of the configmap goes like this:</p>
<pre><code>apiVersion: v1
data:
  mapRoles:  &lt;default options&gt;
  mapUsers: |
    - userarn: arn:aws:iam::&lt;root id&gt;:root
    username: #there should be a username value on this line, but it's missing in my configmap; presumable this is the cause
      groups:
      - system:bootstrappers
      - system:nodes
</code></pre>
<h2>Update 2</h2>
<p>Tried to use serviceAccount token, got an error:</p>
<pre><code>Error from server (Forbidden): configmaps &quot;aws-auth&quot; is forbidden: User &quot;system:serviceaccount:kube-system:aws-node&quot; cannot get resource &quot;configmaps&quot; in API group &quot;&quot; in the namespace &quot;kube-system&quot;
</code></pre>

<p>How did you create your cluster? The IAM user, or IAM role, that you used to actually create it, is grandfathered in as a sysadmin. So long as you use the same credentials that you used for</p>
<p><code>aws eks create-cluster</code></p>
<p>You can do</p>
<p><code>aws eks update-kubeconfig</code>, followed by using kubectl to modify the configmap and give other entites the permissions.</p>
<p>You haven't said what you actually tried. Lets do some more troubleshooting-</p>
<ol>
<li><p><code>system:serviceaccount:kube-system:aws-node</code> this is saying that THIS kubernetes user does not have permission to modify configmaps. But, that is completely correct- it SHOULDNT. What command did you run to get that error? What were the contents of your kubeconfig context to generate that message? Did you run the command from a worker node maybe?</p>
</li>
<li><p>You said &quot;I have access to the root user&quot;. Access in what way? Through the console? With an <code>AWS_SECRET_ACCESS_KEY</code>? You'll need the second - assuming thats the case run <code>aws iam get-caller-identity</code> and post the results.</p>
</li>
<li><p>Root user or not, the only user that has guaranteed access to the cluster is the one that created it. Are there ANY OTHER IAM users or roles in your account? Do you have cloudtrail enabled? If so, you could go back and check the logs and verify that it was the root user that issued the create cluster command.</p>
</li>
<li><p>After running <code>get-caller-identity</code>, remove your .kube/config file and run <code>aws eks update-kubeconfig</code>. Tell us the output from the command, and the contents of the new config file.</p>
</li>
<li><p>Run <code>kubectl auth can-i '*' '*'</code> with the new config and let us know the result.</p>
</li>
</ol>
