Our company has a home-rolled module that makes calls to AWS Parameter Store to retrieve secrets.
I'd like to utilize this module in our Elastic Synthetics project. The usage would be making a call to the module's loadConfig() method right before the SyntheticsConfig object is created in synthetics.config.ts. Parameters retrieved from the call would be injected into the SyntheticsConfig class downstream and then picked up by the synthetics via the param parameter.
The only issue is that loadConfig has asynchronous code and the code that creates the SyntheticsConfig object (export default (env) => {}) is synchronous. I was wondering if there was an undocumented way to create SynethticsConfig in an asynchronous manner?
Any additional information regarding best practices for retrieving configuration data for synthetics would be welcomed as well.
Meanwhile i will suggest you maybe create a helper function which you can call before every journey in before step or maybe create a dedicated step for reading secrets.
Other way would be to use Synthetics app global params in UI. Those are auto injected into every journey.
Thank you for the prompt reply. The only issue I can see with embedding the loadConfig() logic in an async function at the synthetic level is that it would be making calls to AWS Parameter Store every time it runs. We will eventually have quite a number of synthetics and having each one hit PS every couple minutes seems like it might not be ideal, since the config data is only needed once.
That's great that you're open to discussing enhancing synthetics.config.ts to support async operations.
I'll also investigate the global params in the UI option as well as the helper function code you linked.
Any of these options would work and would not run in to the multiple calls limit that you have mentioned. But, looking at your use-case the easiest would be storing them ideally on the Global params as it makes it easier to support both Lightweight and Browser based monitors.
I would like to few other questions before we decide its worth supporting async fetching of the config itself.
Are you interested in fetching the config for managing the monitors on the Synthetics Kibana UI or for running the tests locally on a CI or Dev machine.
Are these remote secrets used across all monitors including lightweight monitors if you are planning to have few?
Thanks in advance and Please let us know if you have any other questions or feedback.
Thank you for the very informative reply. We are also considering a 4th options which would decrypt an encrypted secret that is set in synthetics.config.ts, effectively bypassing the need to call Parameter Store altogether. So essentially:
That being said, it still would be nice to leverage existing modules in an async fashion, if need be. To answer your questions:
We are interested in both of those scenarios. If it wasn't already apparent, I should mention that we house our current synthetics in a project (under Gitlab source control). Any engineer interested in developing synthetics can clone the project and test locally before commiting any new changes. We have a .gitlab-ci.yml pipeline that uses the push command to deploy to Kibana instances in our various environments. The --param option looks like it would be very handy for this.
Some are and some aren't. We have synthetics that use the same configuration data and some synthetics that have their own configuration data that no other synthetic uses.
Hope that helps!
I should mention that we're not 100% sure we're going with implementation #4. I'm going to keep playing around with it, but it looks like a promising, easy to implement, non-async alternative to keeping secret strings secret.
We are working on supporting the Async fetching of information inside the Config file, which would be available in the following releases. Please watch out this enhancement issue for more details.
For the time being, any of the options proposed or the 4th option you mentioned would work just fine.
As its just JS, you could also just fetch the file on exec and just use the params
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.