How to get "this" device's uuid from node sdk

Hi,

I’m trying to setup a fleet of local pi3 servers which all need to communicate with a distant api server.
They all need to authenticate with their own credentials, so I thought I’d use device environment variables to store these individual credentials and get them from the node sdk on boot.

Now I’m actually getting the environment variables successfully using balena.models.device.envVar.getAllByApplication('my-app'), but I expected to get only the variables of the machine performing the call to the balena api through the sdk.
Instead of this I get the environment variables of all the devices.
It seems I could pick the right ones if only I knew the device’s uuid, but I can’t figure out how to get this uuid from my node program.

Is this even possible, or am I supposed to create an application per server (which doesn’t sound like the right thing to do for the exact same node program) ?
Maybe I missed a specific method in the documentation ?

Ok, nevermind, it was me being stupid.
All vars are accessible from process.env (I guess that’s why they are called environment variables), so the sdk is not even needed.
Everything working great now :slight_smile:

Hi @joseph,

I am glad you were able to figure this out! Please let us know if you have any further issues deploying to balenaCloud.

Hi @joseph,

I am glad you were able to figure this out! Please let us know if you have any further issues deploying to balenaCloud.

Thanks !

So I guess the answer to my original question (how to get “this” device’s uuid from the sdk) lies in the solution I found : you could match a device env var with its uuid when parsing the result of

balena.models.device.envVar.getAllByApplication('my-app')

(In case it would be helpful to someone)