grafana / k6-cloud-feature-requests

The place to propose, dicuss and vote for k6 Cloud features and ideas.
9 stars 1 forks source link

Add support for environment variables (incl. secrets) #11

Closed dgzlopes closed 1 year ago

dgzlopes commented 3 years ago

Instead of passing my secrets as environment variables with the CLI all the time, I would love to store these in k6 Cloud and access them from all my scripts. Maybe these secrets can be set per organization, project, or account.

GitHub example: gitexample

na-- commented 3 years ago

Given that this would almost certainly be implemented as k6 environment variables, it might be in a slight conflict with https://github.com/k6io/cloud-feature-requests/issues/9, since we probably don't want to display the values of secrets in the UI, but want to display the values of non-secret environment variables.

dgzlopes commented 3 years ago

Yup, probably implementing it with environment variables is the best!

I think that secrets managed by k6 cloud can have some kind of prefix. It's not perfect, but it's a "quick" workaround for #9.

robingustafsson commented 3 years ago

Yes, this is something we plan to implement. There's an initial project doc for it. What we've discussed previously is that it would allow for env var collections (on a project level) where you could switch between different sets of env vars via the k6 CLI, something like k6 cloud --env-collection "production" script.js. Each env vars defined in a collection in the cloud should be able to be marked as secret and would be treated as such when displayed, eg. on the result page. Any env var defined using k6 cloud -e NAME=VALUE would override any matching env var from a collection. This is something that's been requested by customers.

PkHutch commented 2 years ago

TLDR: Bump

Adding to make a bit more noise as this would be pretty beneficial, in our particular use case it would be because it would be nice for users to run tests on k6 Cloud from their local without being directly exposed to the auth token necessary for testing an API.

The auth token can be passed in via the command line, but this requires the user to have local access to the token, which is what is I'm hoping to avoid.

I was thinking maybe it would be possible to play around with scenarios, but I'm not sure if storing a token in a scenario is a good idea.

PaulMEdwards commented 2 years ago

I inquired with Support asking whether/where I could find ENV var management in the Cloud UI and was directed to this issue and also told:

The team is currently working on implementing this feature, and we are testing it on our side. There's no concrete release date at the moment.

markjmeier commented 1 year ago

This has been implemented - apologies for being slow to update this issue. Cloud Envs can be set within the k6 cloud: https://k6.io/docs/cloud/manage/environment-variables/#manage-environment-variables