Matt
09/29/2020, 10:36 PMnicholas
Secret
task from within another task by calling its .get
method, like such:
token = Secret("SOME_SECRET").get()
from prefect import Flow, task
from prefect.client import Secret
@task
def my_task():
my_secret = Secret("MY_SECRET").get()
# do something with secret
with Flow("My Flow") as flow:
my_task()
Matt
09/30/2020, 12:34 AMChris White
SOCRATA_TOKEN
as an environment variable in the process that you ran python myflow.py
from?PREFECT__CONTEXT__SECRETS__MY_SECRET
environment variable, depending on which pattern you preferMatt
09/30/2020, 12:58 AMtoken = EnvVarSecret("SOCRATA_TOKEN", raise_if_missing=True)
from my 'with flow()' works fine. i can get the secret and pass it to my tasks as a parameter. i'm hoping there's a way to access it from my task either from context, config or something else so i don't have to explicitly pass it each time as a parameter. for instance i have a bunch of tasks that run against a database and they all need a DSNChris White
PREFECT__CONTEXT__SECRETS__SOCRATA_TOKEN=value
and then pull it from prefect.context.secrets["SOCRATA_TOKEN"]
within your tasks, without making it an explicit task itselfMatt
09/30/2020, 3:09 AM