Hi everybody !
I'm trying to package a subflow as a module. This subflow should transparently subscribe to a MQTT topic and change it's output accordingly.
It will be deployed on a Kubernetes cluster, and the goal is to have the MQTT broker configuration node retrieve it's credentials from environment variables. The MQTT settings of this node are implementation details, and ideally I'd like to hide all of them including the credentials, to avoid users breaking anything.
I searched a bit, and found somewhere (maybe on this forum, but I can't find the post anymore Found it again: https://groups.google.com/g/node-red/c/Dfhkiu9X8r0/m/vz2URAdsBgAJ) that it may be possible to just include them on the node in the flows.json file like so:
[
// previous nodes...
{
"id": "338acaed95291164",
"type": "mqtt-broker",
"name": "Semi-public broker",
"broker": "my-mqtt-broker.com",
"port": "8883",
"tls": "e422096c3f00881b",
"clientid": "",
"autoConnect": true,
"usetls": true,
"protocolVersion": "5",
"keepalive": 60,
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": "",
"credentials": {
"user": "${MQTT_BROKER_USERNAME}",
"password": "${MQTT_BROKER_PASSWORD}"
}
},
// next nodes ...
],
And by extension, maybe I could do the same in my subflow json. This would be perfect for my use case as the credentials are just references to environment variables so there is no sensitive data stored in the subflow json file, and the subflow would be self-contained.
When I tried, at first it seemed like everything would be working fine as the credentials were picked up by the editor before packaging it.
However, at runtime, it cannot connect to the broker, and it seems like the credentials are undefined. Setting the same credentials in flows_cred.json works as expected.
Only official documentation I could find about inline credentials in a flow is for the POST /flows endpoint ( POST /flows : Node-RED ) which I guess is kinda unrelated to the way the runtime reads the flow.json file and the packaged subflows.
So my question is, is that use case supported ? Has anyone done that ?
Or was it not supposed to be picked up by the editor which is why it confuses me ?
Thanks for your help !
Edit 1
I'm running Node-RED v4.1.4
Edit 2
I found a few related posts including
When considering exported flows, the answer makes sense, but in my case this is about flows/subflows which are edited manually to include the env variables to use when imported
Edit 3
Found again the post where @knolleary mentionned flows can include credentials

