Hello! I'm trying to run a DBTShellTask using pref...
# prefect-server
e
Hello! I'm trying to run a DBTShellTask using prefect cloud. I have a lot of my connection details stored as Prefect secrets. It looks like when prefect generates the profiles.yml file for this task it is storing literal values instead of injecting the Prefect secrets. Is there a way to inject these into the dbt_kwargs argument?
Copy code
with Flow(
    "dbt",
    storage=Docker(
        path="/flow.py",
        stored_as_script=True
    ),
    run_config=ECSRun()
) as flow:

    repo = pull_dbt_repo()
    dbt_kwargs = {
            "type": "postgres",
            # User/password auth
            "user": PrefectSecret("DEV_DB_USER"),
            "password": PrefectSecret("DEV_DB_PASSWORD"),
            "database": PrefectSecret("DEV_DB_NAME"),
            "port": PrefectSecret("DEV_DB_PORT"),
            "threads": 1,
            "client_session_keep_alive": False,
        }
    deps = dbt(
        command='dbt deps',
        dbt_kwargs=dbt_kwargs
    )



flow.run()
it's generating this in the profiles.yml file which is causing a syntax error for dbt
dev:
 outputs:   null:    client_session_keep_alive: false    database: !!python/object:prefect.client.secrets.Secret     name: DEV_DB_NAME    password: !!python/object:prefect.client.secrets.Secret     name: DEV_DB_PASSWORD    port: !!python/object:prefect.client.secrets.Secret     name: DEV_DB_PORT    threads: 1    type: postgres    user: !!python/object:prefect.client.secrets.Secret     name: DEV_DB_USER  target: null ~
k
Hey @Eric Mauser, this is odd. Could you try defining the secerets within the
dbt()
call and see if that changed anything?
Does it happen for both
flow.run()
and a registered flow?
e
🤦‍♂️ you nailed it. Seems to have been a registration issue. after registering the error goes away. thank you!
k
Oh I was just asking. Glad you got it sorted! I expect this to work with
flow.run()
as well as long as you have
PREFECT__CLOUD__USE_LOCAL_SECRETS=false