Cannot read environment variables in endpoints.yml

In my EC2 instance endpoints.yml cannot read environment variables.

In the yml file I set the env variables in the following snippet

action_endpoint:
  url: ${RASA_USER_APP}

And display the next error message

14|rasa_ap | RasaException: Error when trying to expand the environment variables in '${RASA_USER_APP}'. Please make sure to also set these environment variables: '['${RASA_USER_APP}']'.

I tried to activate and desactivate my venv and nothing changed. Display same error message

Also I changed the yml file changing ${ENV_VARIABLE} to {{ENV_VARIABLE}} or '${ENV_VARIABLE}'and display errors in the file endpoints file.

Someone have any idea what happened?

Hi! I´m not sure if my answer will help, as I´m not running Rasa in an EC2 instance, but locally. However, I had the same issue (I have all env vars stored in an .env file in the actions folder) and I resolved it by running the following command before starting the rasa server:

for powershell:

Get-Content "./actions/.env" | ForEach-Object {
if ($ *-match "^\s*([^#].* ?)\s*=\s*(.* )\s_$") {
$name = $matches[1]
$value = $matches[2]
[System.Environment]::SetEnvironmentVariable($name, $value, "Process")
}
}

For unix-based systems:

export $(grep -v '^#' ./actions/.env | xargs)

That way I set the vars in the terminal before running the server and the endpoints file was able to access them

I hope this helps!

Thanks for your reply:

Based in the unix command I found another one:

export $(grep -v '^#' .env | xargs -0)

This exported successfully but display the same error.

I forget to explain that I’m using PM2 to restart the application.

Is this maybe the cause?

Or anyone has a better implementation.

hmm, that´s strange. After running the command, can you access the vars through the cli?