<p>I'm trying to create K8s cluster on Amazon EKS with Terraform. All the code is on github: <a href="https://github.com/amorfis/aws-eks-terraform" rel="nofollow noreferrer">https://github.com/amorfis/aws-eks-terraform</a></p>

<p>access_key and secret are configured for the user which has the necessary policy, as seen in README.md. </p>

<p>I run <code>terraform init</code>, then <code>terraform apply</code> and it fails with following error: 
<code>module.eks.null_resource.update_config_map_aws_auth (local-exec): error: unable to recognize "aws_auth_configmap.yaml": Unauthorized</code></p>

<p>I also checked in the modules, and it looks like it should create 2 files: <code>aws_auth_configmap.yaml</code> and <code>kube_config.yaml</code>, but instead I can see 2 different files created: <code>kubeconfig_eks-cluster-created-with-tf</code> and <code>config-map-aws-auth_eks-cluster-created-with-tf.yaml</code>. </p>

<p>The problem here seems to be that you try to use an AssumedRole but then the module attempts to do local exec which is why it fails. </p>

<p>What you would be required is something like this where you add 
 "kubeconfig_aws_authenticator_env_variables" to the module taken from the official example like below - </p>

<pre><code>module "my-cluster" {
  source       = "terraform-aws-modules/eks/aws"
  cluster_name = "my-cluster"
  kubeconfig_aws_authenticator_env_variables = {
             AWS_PROFILE = "NameOfProfile"
  }
  subnets      = ["subnet-abcde012", "subnet-bcde012a", "subnet-fghi345a"]
  vpc_id       = "vpc-1234556abcdef"

  worker_groups = [
    {
      instance_type = "m4.large"
      asg_max_size  = 5
    }
  ]

  tags = {
    environment = "test"
  }
}
</code></pre>

<p>Note:  The following is added - </p>

<pre><code> kubeconfig_aws_authenticator_env_variables = {
    AWS_PROFILE = "NameOfProfile"
  }
</code></pre>

<p>Replace the value of profile  with whatever name you have provided with in the ~/.aws/config. </p>
