Question

How to use environment variables specified in the app spec as values for fields inside the app spec?

Posted November 1, 2021 147 views
CI/CDDigitalOcean API and CLI (doctl)DigitalOcean App Platform

Lets say you have specified an encrypted app wide environment variable in the app spec. Now you wish to use this environment variable as a value for a field inside the app spec. Is it possible?

Concrete example:
I wish to forward logs to Logtail. In order to do that, I need to set up log_destinations and provide a token. I don’t wish to upload the token to version control, and thus instead specify the token as an encrypted app wide environment variable. Is it possible to somehow use this same environment variable as value for the “token” field?

If not, is there a way to inject environment variables into the app spec file e.g. from github environment variables?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hey there!

This is a good idea, but unfortunately not something that App Platform supports. ENV variables would only be available within the application itself and not readable by the app spec file. I would suggest adding it to our ideas page: DigitalOcean Ideas

You possibly could create those variables outside of version control on your local machine or use Github variables to store them. You could then write your own script to generate your app spec with those variables and deploy your app with DOCTL

Hope it helps!
Nate