Can I use local environment variables from my execution environment in my synthetics journeys (e.g., from the Kubernetes pod where the test runs), and if so, how?
I am using
@elastic/synthetics-1.4.0 to write user journeys and push them to our Elastic Synthetics environment, which runs in Elastic Cloud 8.10.3. I then schedule them to run in private locations, using the
When I use environment variables, using the
process.env.VARIABLE format, it bundles the variables from the machine used to push the tests to Elastic Cloud. As far as I can tell, it does this by replacing references in to environment variables in
synthetics.config.ts or in individual script files with strings.
The issue lies in using a CI/CD pipeline to push tests to Elastic. Environment variables are not usually defined in the CI/CD pipeline, so I would like to simply be able to define my environment variables as a Kubernetes secret, mount them in the pod, and use them in my scripts, similar to how I'm able to use environment variables in other Elastic Agent integrations.
A second issue with CI/CD deployments when using environment variables is that, as far as I can tell, if the value of the local environment variable changes, it does not appear to recognize that as a change in the script, so it will not push the script with the updated variable value. The workaround is to first delete the remote script, then deploy it again, which requires multiple pull requests and deployments, so it doesn't lend itself well to a CI/CD pipeline.
Another issue, unrelated to CI/CD, is that parameters don't seem to be usable in
playwrightOptions, so when it is necessary to set
playwrightOptions.httpCredentials, it must be done either using environment variables or by including the secret in
synthetics.config.ts. However, Kibana shows
playwrightOptions (including the password) as clear text, which is insecure, since anybody who has access to edit the script can then see the credentials.
My question is: Can I use local environment variables from my execution environment (e.g., from the Kubernetes pod where the test runs), and if so, how?