R
Railwayβ€’2mo ago
rpuls

Service depending on secret from other service - how to share value between services?

Hi, I have a project with 2 separate node services. service A programatically generates a unique secret (api key) first time it is build, and saves it to a postgres database. srvice B - starts building right after service A has finished building, and service B depends on the api key from service A, to build - as the two services communicates during service B build. Normally I would pass it via environment variables, but since it is generated programatically from service A, that is not an option. I would prefer not giving service B database access. Currently I am exposing the api key on a endpoint in service A, and fetching it from service B with a script before build starts. So I do have a working solution. But I would prefer not exposing secrets on an endpoint, and ideally pass the value from A to B in a smoother way. I was hoping to be able to set a Railway project wide global value, that I can read from all other serviced - like a shared environment variable. But it is my understading that it is not possible to programatically set environment variables from within services.. I'm looking for inspiration and ideas - please suggest! πŸ™‚
Solution:
how you do it now with an api endpoint is perfectly fine and standard practice. heres just one example - https://www.meilisearch.com/docs/reference/api/keys#keys...
Jump to solution
5 Replies
Percy
Percyβ€’2mo ago
Project ID: N/A
SCIENTIFIC
SCIENTIFICβ€’2mo ago
I believe the railway API supports this (bc the public API is what runs the dashboard IIUC): https://docs.railway.app/guides/public-api ...so service A would have a railway token and API access and would set shared variable.
Railway Docs
Use the Public API | Railway Docs
Documentation for Railway
Solution
Brody
Brodyβ€’2mo ago
how you do it now with an api endpoint is perfectly fine and standard practice. heres just one example - https://www.meilisearch.com/docs/reference/api/keys#keys
rpuls
rpulsOPβ€’2mo ago
Thanks! if this is common practice I'm happy.
Brody
Brodyβ€’2mo ago
no problem!
Want results from more Discord servers?
Add your server