Support Questions

Find answers, ask questions, and share your expertise

NIFI exceute script : Not reading the psql password

avatar
Explorer

Hi,

I have installed NIFI on EC2 instance where I am invoking PostgreSQL psql utility. When I invoke the following command from the EC2 instance, it works fine:

psql --host=<AWS RDS host>--port=5432 --dbname=<DBname> --username=<DB user> --no-password --command="create database kiran_test_10"
This creates the database

But when I embed the same command in the groovy script and try to execute from the NIFI execute processor, it throws out

"Error: psql: fe_sendauth: no password supplied"

I have setup an environment variable PGPASSWORD on the EC2 instance. The psql command when executed on the EC2 instance is able to pick up the password but when executed from the NIFI execute script processor is not picking up the password.

Do I need to configure environment variables differently on EC2 for NIFI to read them?

Please let me know

1 ACCEPTED SOLUTION

avatar
Master Guru

An alternative to using an environment variable is to use the file-based Variable Registry, where you could create a file perhaps called var_registry.properties with the entry

PGPASSWORD=<my_pg_password>

And edit conf/nifi.properties to use that file for the registry:

nifi.variable.registry.properties=var_registry.properties

Then you could use PGPASSWORD in your groovy script the same way you'd use an environment variable:

${PGPASSWORD}

View solution in original post

2 REPLIES 2

avatar

Are you sure this environment variable is set for the NiFi user, and not just for the user you are ssh'd in as? A test for this would be to invoke a common system variable like USER and see what you get.

avatar
Master Guru

An alternative to using an environment variable is to use the file-based Variable Registry, where you could create a file perhaps called var_registry.properties with the entry

PGPASSWORD=<my_pg_password>

And edit conf/nifi.properties to use that file for the registry:

nifi.variable.registry.properties=var_registry.properties

Then you could use PGPASSWORD in your groovy script the same way you'd use an environment variable:

${PGPASSWORD}