Need help in passing AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN to run tests on AWS Kubernetes Cluster

Hello,

I need to run tests on Kubernetes cluster and it works with your docker image when i try on local machine as i have all the AWS config, credentials file and KUBECTL config stored on my local machine but when i try to run the same on Jenkins pipeline it fails as the docker image is not having AWS config file and KUBECTL config on the image. So as per the suggestion from this link Docker Usage — v12.0.0 - check and report on AWS service usage and limits i tried using the below command but it is unable to run kubectl commands.

Docker command

docker run --rm --user=root -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
	-e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
	-e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
	-v /var/lib/jenkins/workspace/reports:/opt/robotframework/reports:Z \
	-v /var/lib/jenkins/workspace/tests:/opt/robotframework/tests:Z \
	-v /var/lib/jenkins/workspace/resources:/opt/robotframework/resources:Z \
         1234.dkr.ecr.us-east-1.amazonaws.com/tests/robot:latest

Error

+ docker run --rm --user=root -e AWS_ACCESS_KEY_ID=ABCDEFGHIJKNL
"docker run" requires at least 1 argument.
See 'docker run --help'.

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

Any help on this is really appreciated.

Thanks in advance.

Hi Parames,

I’m no expert on these things as I don’t really use AWS and docker myself, so take my suggestion with a grain of salt.

Looking at the error, the first clue is:

"docker run" requires at least 1 argument.

and the second clue is:

+ docker run --rm --user=root -e AWS_ACCESS_KEY_ID=ABCDEFGHIJKNL

I suspect the issue is the \ line continuations are actually being taken as new lines by your management tool? I’d suggest removing these \ and make your command a single long line of text.

Hope that helps,

Dave.

Thanks Dave. I made it single line but still same issue.

“docker run” requires at least 1 argument.

Like @damies13 said, the error is the missing argument. In your command it ends with the docker image name.
Just add the command you want :slight_smile:

Please take a look at this Docker

docker run \
    -e AWS_ACCESS_KEY_ID=<your AWS key> \
    -e AWS_SECRET_ACCESS_KEY=<your AWS secret> \
    -e AWS_DEFAULT_REGION=<your AWS region e.g. eu-central-1> \
    -e AWS_BUCKET_NAME=<name of your S3 bucket> \
    ppodgorsek/robot-framework:latest

I was trying to replicate the same.

I assume that when running on AWS you upload the tests to some directory (you have volumes defined in your initial message). Are the files there?

But if the error message is the same and you have the full command in a single line, I really can’t help.

Hi @HelioGuilherme66 - Yes, i have the files in a directory and normal tests are running which doesn’t use aws or kubectl commands.

I really don’t understand what is going on, because the error message if for docker run and the missing command.
Did you tested locally the docker image?

Maybe you need to download the 1GB image first in the AWS bucket.

docker image pull ppodgorsek/robot-framework:latest

(I too am not a user of cloud envs)

@HelioGuilherme66 @damies13 - Hi, Finally i found the issue and it was due to additional line added to AWS ACCESS KEY variable.

Here is the solution amazon web services - aws s3 ls: An HTTP Client raised an unhandled exception: Invalid header value - Stack Overflow

But thanks for checking.

2 Likes