The primary error: [Errno 2] No such file or directory: 'aws' This appears before the 403 error and this is a indication that the Lambda function can't find the AWS CLI, which is needed for the token generation in your kubeconfig. This is why you're being identified as system:anonymous
Hence Suggest to removed the AWS CLI dependency *in the kube_config dictionary under the users section *
Please Replace this with direct boto3 token generation
'users': [{ 'name': cluster_name, 'user': { 'exec': { # This part tries to execute the AWS CLI 'apiVersion': 'client.authentication.k8s.io/v1beta1', 'command': 'aws', # <-- This is trying to use the AWS CLI command 'args': ['eks', 'get-token', '--cluster-name', cluster_name] } } }]