Aws-cli: aws eks update-kubeconfig fails with error TypeError: 'NoneType' object is not iterable

Created on 15 Jan 2020  路  5Comments  路  Source: aws/aws-cli

I just received a new MacBook with MacOS Catalina. I used the latest AWS CLI Bundle to install the AWS CLI on the MBP.

`gregory.bonk@greg-bonk-mbp:~/workspace$ unzip awscli-bundle.zip
Archive: awscli-bundle.zip
inflating: awscli-bundle/install
inflating: awscli-bundle/packages/PyYAML-5.2.tar.gz
inflating: awscli-bundle/packages/pyasn1-0.4.8.tar.gz
inflating: awscli-bundle/packages/docutils-0.15.2.tar.gz
inflating: awscli-bundle/packages/botocore-1.14.3.tar.gz
inflating: awscli-bundle/packages/s3transfer-0.3.0.tar.gz
inflating: awscli-bundle/packages/urllib3-1.25.7.tar.gz
inflating: awscli-bundle/packages/python-dateutil-2.8.0.tar.gz
inflating: awscli-bundle/packages/virtualenv-16.7.8.tar.gz
inflating: awscli-bundle/packages/colorama-0.4.1.tar.gz
inflating: awscli-bundle/packages/jmespath-0.9.4.tar.gz
inflating: awscli-bundle/packages/futures-3.3.0.tar.gz
inflating: awscli-bundle/packages/awscli-1.17.3.tar.gz
inflating: awscli-bundle/packages/rsa-3.4.2.tar.gz
inflating: awscli-bundle/packages/six-1.14.0.tar.gz
inflating: awscli-bundle/packages/setup/setuptools_scm-3.3.3.tar.gz
inflating: awscli-bundle/packages/setup/wheel-0.33.6.tar.gz

gregory.bonk@greg-bonk-mbp:~/workspace$ sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Running cmd: /usr/local/opt/python@2/bin/python2.7 virtualenv.py --no-download --python /usr/local/opt/python@2/bin/python2.7 /usr/local/aws
Running cmd: /usr/local/aws/bin/pip install --no-binary :all: --no-cache-dir --no-index --find-links file://. setuptools_scm-3.3.3.tar.gz
Running cmd: /usr/local/aws/bin/pip install --no-binary :all: --no-cache-dir --no-index --find-links file://. wheel-0.33.6.tar.gz
Running cmd: /usr/local/aws/bin/pip install --no-binary :all: --no-build-isolation --no-cache-dir --no-index --find-links file:///Users/gregory.bonk/workspace/devops-application/infrastructure/awscli-bundle/packages awscli-1.17.3.tar.gz`

Checking the install I see this...

gregory.bonk@greg-bonk-mbp:~/workspace$ which aws /usr/local/bin/aws gregory.bonk@greg-bonk-mbp:~/workspace/$ /usr/local/bin/aws --version aws-cli/1.17.3 Python/2.7.17 Darwin/19.2.0 botocore/1.14.3

Then when running a command to get an EKS cluster configuration...

aws eks update-kubeconfig --name my-eks --region us-west-2

This is the error...

'NoneType' object is not iterable

In the debug I see that there is a response, coming back. Appears to be something with parsing it ?

https://gist.github.com/TechnicalMercenary/48f15680f1fcd506b256e84157f08e30

customization eks-kubeconfig

Most helpful comment

After deleting my existing _~/.kube/config_ file I ran the update-kubeconfig again and now it works perfectly fine.

Perhaps it was an issue with my config's format or something ? Here's what it used to look like...

$ cat ~/.kube/config
apiVersion: v1
clusters: null
contexts: null
current-context: arn:aws:eks:us-west-2:3456345634:cluster/my-eks
kind: Config
preferences: {}
users: null

All 5 comments

After deleting my existing _~/.kube/config_ file I ran the update-kubeconfig again and now it works perfectly fine.

Perhaps it was an issue with my config's format or something ? Here's what it used to look like...

$ cat ~/.kube/config
apiVersion: v1
clusters: null
contexts: null
current-context: arn:aws:eks:us-west-2:3456345634:cluster/my-eks
kind: Config
preferences: {}
users: null

I've stumbled upon this again, and I'm going to speculate that the AWS CLI needs to be able to handle config files a little more robustly.

Here's a couple of flows that I've come up with that causes this to fail....

Flow 1

// Start with fresh file
rm ~/.kube/config

// Update with the context you want
aws eks update-kubeconfig --name my-cluster --region us-west-2

// Use KubeCtl to delete the context
kubectl config delete-context arn:aws:eks:us-west-2:000000000000:cluster/my-cluster

// RE-Apply the Config
aws eks update-kubeconfig --name my-cluster --region us-west-2

Tried to insert into contexts, which is a not a

Here is my context file before the Re-Apply

```apiVersion: v1
clusters:

  • cluster:
    certificate-authority-data: {...snip...}.sk1.us-west-2.eks.amazonaws.com
    name: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    contexts: null
    current-context: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    kind: Config
    preferences: {}
    users:
  • name: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    user:
    exec:
    apiVersion: client.authentication.k8s.io/v1alpha1
    args:

    • --region

    • us-west-2

    • eks

    • get-token

    • --cluster-name

    • my-cluster

      command: aws

      env: null

# Flow 2

// Start with fresh file
rm ~/.kube/config

// Update with the context you want
aws eks update-kubeconfig --name my-cluster --region us-west-2

// Use KubeCtl to delete the context
kubectl config delete-cluster arn:aws:eks:us-west-2:000000000000:cluster/my-cluster

// RE-Apply the Config
aws eks update-kubeconfig --name my-cluster --region us-west-2

'NoneType' object is not iterable

### Config before re-apply

apiVersion: v1
clusters: null
contexts:

  • context:
    cluster: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    user: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    name: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    current-context: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    kind: Config
    preferences: {}
    users:
  • name: arn:aws:eks:us-west-2:000000000000:cluster/my-cluster
    user:
    exec:
    apiVersion: client.authentication.k8s.io/v1alpha1
    args:

    • --region

    • us-west-2

    • eks

    • get-token

    • --cluster-name

    • my-cluster

      command: aws

      env: null

      ```

Apparently, the AWS CLI will need to take into account the changed behavior, see how the upstream kubernetes issue was closed: https://github.com/kubernetes/kubernetes/issues/88524

thanks all, i had same issue, solved it with rm ~/.kube/config as well

Thanks for the report and the detailed descriptions on how to get it to fail. I'll confer with the EKS team on how to handle this, as it is a CLI customization.

Was this page helpful?
0 / 5 - 0 ratings