Is it possible to install AWS cli inside K6 official docker image

building new docker image based on K6’s official docker image to run across multiple CICD workflows.

FROM grafana/k6

# copy k6 test script
COPY dist/test.js /app/
COPY dist/test.js.map /app/

# set working directory
WORKDIR /app

# Here need to run aws cli command to extract secrets from AWS SecretsManager and pass them via -e flags

# CMD ["run", "test.js", "-e", "secret=MyBigSecret"]

However before running k6 script, need to extract secrets from AWS SecretsManager which is used inside of k6 test script.
I can extract secrets and pass them with docker run command as env variables, but this requires to update more than 20 CICD workflows and expose those details, all I want to bake into single new docker image without exposing details.

or is it possible to create a node docker image and install K6 there?
Found this example, however it will throw error Error: Cannot find module ‘k6’

FROM node:14.7.0

#Install K6
WORKDIR /tmp
ADD https://github.com/loadimpact/k6/releases/download/v0.27.1/k6-v0.27.1-linux64.tar.gz /tmp/k6-v0.27.1-linux64.tar.gz
RUN tar -xzf k6-v0.27.1-linux64.tar.gz
RUN mv k6-v0.27.1-linux64/k6 /usr/bin/k6

#Install NPM dependencies
COPY loadtest-home /loadtest-home
WORKDIR /loadtest-home
RUN npm ci

ENTRYPOINT node index.js

Hi @markus,
welcome to the community forum :tada:

Is it possible to install AWS cli inside K6 official docker image

Unfortunately not. The current Docker image has the goal to be as light as possible and general purpose where adding a CLI for a dedicated service doesn’t respect these principles.

or is it possible to create a node docker image and install K6 there?

Yes, it is the solution you should look into.

Found this example, however it will throw error Error: Cannot find module ‘k6’

You should update your k6 version, v0.27 is a very old version. Where did you find this example? In the documentation?

Can you report what the command that RUN npm ci executes is, please?

I hope it helps.

2 Likes