<p>I have created a EC2 instance where Jenkins is running connected to my GitHub account. The following are the two steps of my Jenkins pipeline:   </p>

<pre><code>pipeline {
    agent any
    stages {
        stage('Kubernetes cluster') {
            steps {
                withAWS(region:'us-west-2', credentials:'aws-kubernetes') {
                    sh '''
                    if [ ! aws cloudformation describe-stacks --region us-west-2 --stack-name eksctl-EmaJarK8sCluster-cluster ] ; then

                        if [ ! aws cloudformation describe-stacks --region us-west-2 --stack-name eksctl-EmaJarK8sCluster-nodegroup-standard-workers ] ; then

                            eksctl create cluster \
                            --name EmaJarK8sCluster \
                            --version 1.13 \
                            --nodegroup-name standard-workers \
                            --node-type t2.small \
                            --nodes 2 \
                            --nodes-min 1 \
                            --nodes-max 3 \
                            --node-ami auto \
                            --region us-west-2 \
                            --zones us-west-2a \
                            --zones us-west-2b \
                            --zones us-west-2c \

                        fi

                    fi
                    '''
                }
            }
        }

        stage('Configuration file cluster') {
            steps {
                withAWS(region:'us-west-2', credentials:'aws-kubernetes') {
                    sh '''
                        aws eks --region us-west-2 update-kubeconfig --name EmaJarK8sCluster
                    '''
                }
            }
        }
    }
}
</code></pre>

<p>The first step creates a Kubernetes cluster if it doesn't exist, the second one creates a configuration file for that cluster. This step works pretty well and creates two cloudformation stacks and one EC2 machine where the Kubernetes cluster is running.</p>

<p>The second stage fails with the following error:</p>

<pre><code>Invalid choice: 'eks', maybe you meant:

  * es
</code></pre>

<p>After reading a couple of tutorial I've found out that I needed to update <code>awscli</code> to version <code>1.18.57</code> in order to have the <code>eks</code> command available. So I've logged into my Jenkins machine (not the one dedicated to the k8s cluster) ad I've update the <code>awscli</code>. 
Unfortunately this is not enough. I still get the same error. I can run the command manually into Jenkins the machine but, for some reason, I cannot run it via Jenkins pipeline.</p>

<p>Can someone help me with this problem?</p>

<p>Thanks in advance.</p>

Ema.jar
<p>Can you provide the full path to the <code>aws</code> command? Also add <code>which aws</code> and <code>aws --version</code> to the second stage script, and confirm that output.</p>

<p>The above should highlight the actual path of the command, and the current version. Correct your configuration as needed.</p>
