Access a list of all defined variables in dbt_project.yml

Hi dbt-Community,

I want to extract a list of all user defined variables from the dbt-project.yml so that I can iterate over them in a loop. The names of the variables are not known to me in advance.

I have read the documentation and searched the web, but unfortunately, I couldn’t find a solution. I would be very surprised if this were not possible. Interestingly, dbt gives me exactly what I need when I use the var() macro with a variable that doesn’t exist as error msg:

Compilation Error in operation on-run-start-0 (./dbt_project.yml)
Required var 'myVar' not found in config:
  Vars supplied to on-run-start-0 = {
      "enable_ghost_records": true,
      "ext_full_refresh": true,
      "external_tables_schema": "DWH_01_EXT",
      "hash": "SHA"
      }"
  }

Does anyone have an idea?