Enabling expressions in credentials

Hello, i’m trying to use expressions (using $env) while creating credentials but for every field that i select for creating an expression, the form fields are presented as read only (purple color). I don’t have this problem using expressions in nodes. N8N_BLOCK_ENV_ACCESS_IN_NODE is false, and CREDENTIALS_OVERWRITE_DATA is currently null. How do i enable entry of expressions in credential creation?

thanks
v0.198.2

Did you check this thread: Adding Expressions to Credentials - #8 by maxT

Hey @Hash,

Welcome to the community :tada:

What credential are you trying to add an expression to? I have just opened up the Zendesk node and added a new one and it allows me to enter expressions, They won’t normally be read until the workflow runs though.

1 Like

i’m trying to create an AWS credential and a couple of others but the form won’t allow input at all. I’m able to use expressions in nodes without a problem.

Ok i was able to create an expression if i enter the value into the input field first then click the expression tab. This works ok but what i would like to do is use these expressions in CREDENTIALS_OVERWRITE_DATA such as {"aws":{"accessKeyId":"{{$env.MY_KEY_ID}}","secretAccessKey":"{{$env.MY_SECRET}}"}}, however the expression is evaluated as a string instead of switching into expression mode. Is there a way to use the overwrite data variable in expression mode?

Hey @Hash,

That looks like an embed option, Looking at the docs I would expect what you are doing to set it as a string as it doesn’t expect expressions to be used. I am not aware of a way to do this but it could be something that you might be able to able to add to your embed fork if you are using one.

I can of course also get a feature request opened internally for this one.

All good. Really the goal here was to trick N8N into using the IAM instance profile credentials by way of environment vars (because the tokens change often), but i also prefer to turn off env access for nodes. When node env access is disabled, the node is also prevented from accessing the env via the credential. Seems like a lot of work to change the behaviour. For now i’ll just use a custom user and cli creds and set them as static credential overwrites as i know that works. thanks

1 Like