Is there a documented code example anywhere using ...
# ask-community
t
Is there a documented code example anywhere using dbt + the ssh tunnel with port forwarding? This thread talks about it, but I cannot figure out what / how the resources are meant to be configured exactly.
My basic setup is as so, but how do we configure this to use the
get_tunnel
method from the
ssh_resource
? I am clearly missing some fundamental knowledge as to how to the Dagster resources fit together. I know I want it to be called in the assets, but given I am just returning the assets via
load_assets_from_dbt_project
, how do we achieve this?
Copy code
assets = with_resources(
    load_assets_from_dbt_project(
        profiles_dir=DBT_PROJECT_PATH,
        project_dir=DBT_PROFILES,
        use_build_command=False, 
        display_raw_sql=True,
    ),
    {
        "dbt": dbt_cli_resource.configured(
            {
                "project_dir": DBT_PROJECT_PATH,
                "profiles_dir": DBT_PROFILES,
            },
        ),
        "ssh": ssh_resource.configured(
            {
                "remote_host": os.getenv("SSH_HOST"),
                "remote_port": 22,
                "username": os.getenv("SSH_USER"),
                "key_file": "~/.ssh/dagster_rsa",
            }
        ),
    },
)
dbt profile
Copy code
host: localhost
port: 5439
user: xxxxx
pass: xxxxx
dbname: xxxxx
For a final bit of context, what I essentially want to be able to do is run a command equivalent to the below, which authenticates with the SSH server and forwards the local ports.
Copy code
ssh -fN dagster@SSH.SERVER.IP.ADDRESS -i ~/.ssh/dagster_rsa -L 5439:WAREHOUSE.ADDRESS:5439