<p>I have been trying to follow the getting started guide to EKS. 
When I tried to call kubectl get service I got the message: error: You must be logged in to the server (Unauthorized)
Here is what I did:<br>
1. Created the EKS cluster.<br>
2. Created the config file as follows:</p>

<pre><code>apiVersion: v1
clusters:
- cluster:
    server: https://*********.yl4.us-west-2.eks.amazonaws.com
    certificate-authority-data: *********
  name: *********
contexts:
- context:
    cluster: *********
    user: aws
  name: aws
current-context: aws
kind: Config
preferences: {}
users:
- name: aws
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      command: heptio-authenticator-aws
      args:
        - "token"
        - "-i"
        - "*********"
        - "-r"
        - "arn:aws:iam::*****:role/******"
</code></pre>

<ol start="3">
<li>Downloaded and installed latest aws cli</li>
<li>Ran aws configure and set the credentials for my IAM user and the region as us-west-2</li>
<li>Added a policy to the IAM user for sts:AssumeRole for the EKS role and set it up as a trusted relationship</li>
<li>Setup kubectl to use the config file</li>
</ol>

<p>I can get a token when I run heptio-authenticator-aws token -r arn:aws:iam::**********:role/********* -i my-cluster-ame
However when I try to access the cluster I keep receiving error: You must be logged in to the server (Unauthorized)</p>

<p>Any idea how to fix this issue?</p>

<blockquote>
<p>When an Amazon EKS cluster is created, the IAM entity (user or role) that creates the cluster is added to the Kubernetes RBAC authorization table as the administrator. Initially, only that IAM user can make calls to the Kubernetes API server using kubectl.</p>
</blockquote>
<p><a href="https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html#eks-create-cluster" rel="noreferrer">eks-docs</a></p>
<p>So to add access to other <em>aws</em> users, first
you must edit ConfigMap to add an IAM user or role to an Amazon EKS cluster.</p>
<p>You can edit the ConfigMap file by executing:
<code>kubectl edit -n kube-system configmap/aws-auth</code>, after which you will be granted with editor with which you map new users.</p>
<pre><code>apiVersion: v1
data:
  mapRoles: |
    - rolearn: arn:aws:iam::555555555555:role/devel-worker-nodes-NodeInstanceRole-74RF4UBDUKL6
      username: system:node:{{EC2PrivateDNSName}}
      groups:
        - system:bootstrappers
        - system:nodes
  mapUsers: |
    - userarn: arn:aws:iam::111122223333:user/ops-user
      username: ops-user
      groups:
        - system:masters
  mapAccounts: |
    - &quot;111122223333&quot;
</code></pre>
<p>Pay close attention to the <code>mapUsers</code> where you're adding <em>ops-user</em>  together with <code>mapAccounts</code> label which maps the <em>AWS</em> user account with a username on Kubernetes cluster.</p>
<blockquote>
<p>However, no permissions are provided in RBAC by this action alone; you must still create role bindings in your cluster to provide these entities permissions.</p>
</blockquote>
<p>As the amazon documentation(<a href="https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html" rel="noreferrer">iam-docs</a>) states you need to create a role binding on the kubernetes cluster for the user specified in the ConfigMap. You can do that by executing following command (<a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/#kubectl-create-clusterrolebinding" rel="noreferrer">kub-docs</a>):</p>
<p><code>kubectl create clusterrolebinding ops-user-cluster-admin-binding --clusterrole=cluster-admin --user=ops-user</code></p>
<p>which grants the cluster-admin <code>ClusterRole</code> to a user named <em>ops-user</em> across the entire cluster.</p>
