digitalnodecom / node-red-contrib-generic-s3

Generic S3 nodes for use in Node-RED
https://www.npmjs.com/package/@digitalnodecom/node-red-contrib-generic-s3
Apache License 2.0
3 stars 5 forks source link

Unable to use config node with environment variables #77

Open trajche opened 6 months ago

trajche commented 6 months ago

In the node description it's claimed that we can use envvars using $(envvar) synthax inside the config value: image

I tried to replace hardcoded value with Node-RED environment variables but it's not functioning. Instead, I believe the literal string $(s3_apikey) is used as the Key.

image

The error received is error: "Forbidden: Forbidden"

Note: I've been testing with environment variables that are defined in the flow (not in Node-RED system). You can check them out by double clicking the flow tab and then clicking on Environment Variables:

image

rristov60 commented 6 months ago

Hi @trajche, this indeed needs to be looked into and I was able to successfully replicate the issue with the steps that you provided. That being said, I believe that the documentation can be improved as well.

In the documentation, it is not specified what kind of environment variables are in question. As of now, every environment variable reference refers to a system environment variable . In addition to system environment variables, there are process environment variables. These nodes are fully compatible with process environment variables, but the syntax differs from the system environment variables.

Process environment variables are environment variables which are created for the Node-RED process. This is plausible by utilising the function node. First, the process module needs to be imported:

image

And then in the code block, the following code can be used to set process environment variable:

process.env.s3_apikey = "test";

Finally, the process environment variable can be referenced as ${s3_apikey} in an input field, like in the following example:

image