Amateur question here, but how do I reference balena variables in code?
I’m trying to get the following but it doesn’t appear to be working. Any suggestions?
I’d like to be able to toggle the following from the cloud UI with device variables.
$logs_enabled, $process_enabled, $network_enabled
And I’d like to get the following to populate at runtime for the datadog agent to push tags to my host monitor.
In your code, the balena variables you mentioned are available as environment variables inside the balena containers. So, how you reference process environment variables within your code will depend on the language you are using.
I would direct you to our DataDog blog post though if you haven’t seen that. It should provide an interface to manage the configurations you mentioned. If not, let us know, and we’ll do what we can.
Before I do is there a way to define environment variables with placeholder values in code so that they populate the balena ui when pushing? Then a user only has to go to the ui and replace the values instead of also creating the variable itself?
I’ve seen this done with deploy to balena buttons but can’t figure out how to do on private projects.
Great thanks. Is balena.yml only compatible if using a deploy with balena mechanism? Or can it work without the button paradigm and instead work with the traditional “balena push”?
I imagine there might be some state problems, ie. user set variables in the ui, then does a balena push on a repo with an outdated balena.yml - which takes precedence? etc etc.
When you create an application in balenaCloud, do you see an Advanced toggle? If so, you can click that to open other options and drag and drop a balena.yml to the modal window to prepopulate the device and environment variables. This is not available with Starter apps, however, and may still be in beta for other paid accounts.
To include the variables otherwise, you’ll need to create a standard Docker-style .env file (per the Docker documentation.