Hi community! I have a question regarding how and ...
# ask-community
j
Hi community! I have a question regarding how and when environment variables are pulled, and whether I need to pass environment variables to an agent or not. If I have the following python script for a flow
Copy code
import os
from prefect import task

@task
def get_env():
    return os.environ.get("CURRENT_ENV")

with Flow(name="get-env") as flow:
    env = get_env()

flow.register(project="get_env")
and I have “CURRENT_ENV” in my bash/zsh environment variables, and run the flow in with a LocalAgent, then it’s not necessary to pass any environment variables when I execute
prefect agent local start
because the environment variable is already in the local system. But if wanted to run the flow in a non-local environment, say in a Dask cluster in Kubernetes, then I would need to pass environment variables to
prefect agent kubernetes start
?
k
Hello again @Julio Venegas! Yes you can pass it upon agent start
j
Hi Kevin! 😄 sweet, I hadn’t read those two key bullet points, thank you! so envs passed at agent start are available for all flows in the relevant environment 👌
👍 1
k
Yes