I am facing same issue. I have a script placed on a server. Server already has kubectl and aws cli installed.
WHEN SCRIPT IS EXECUTED WITH AWS SSM
script runs eks update kubeconfig and then kubectl command, which fails with below error:
ERROR-------
E0417 15:54:14.627818 31772 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: Get \"http://localhost:8080/api?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"
The connection to the server localhost:8080 was refused - did you specify the right host or port?
WHEN SCRIPT IS EXECUTED DIRECTLY FROM SERVER, IT PASSES THROUGH.
Note: the user in both case is root that is checked with whom.
Please help me if you found a solution.