<@ULVA73B9P> can a work pool obtain env vars from ...
# ask-marvin
m
@Marvin can a work pool obtain env vars from a secret block?
👍 1
m
From the searches in Prefect documentation, here's what I found: 1. Prefect 2.x: - The Prefect 2.x documentation indicates that job variables, including environment variables, can be overridden per deployment or per flow run. However, there is no explicit mention in the search results about directly sourcing these variables from a secret block. For more details, you can refer to the overriding job variables guide. 2. Prefect 3.x: - Similar to 2.x, Prefect 3.x documentation mentions that work pools can utilize environment variables, but it doesn't explicitly state that these can be obtained from a secret block. However, Prefect supports secret management through blocks like
SecretStr
and
SecretDict
to securely handle sensitive information. - For more details, you can check the infrastructure concepts for work pools and block documentation. If you need to use secrets in your environment variables, you can manually fetch secrets in your flow code and then set them as environment variables programmatically. For more precise guidance, you could explore Prefect's extensions or community examples that implement this pattern, as the official documentation might not cover direct integration of secret blocks into work pool environment variables.
n
tldr, yes you can template in secret blocks or variables in either • job overrides (override work pool config for a deployment or flow run) • on the work pool base job template itself
m
@Nate do you have an example of templated secret block?
m
thank you!
n
note that this example will render the secret at deployment time https://github.com/PrefectHQ/prefect/issues/15489
ie your secret value would be stored on the deployment object as a
job_variables
override so, if you don't want that, right now you might have to just load the secret yourself when you need it
alternatively, you could put the secret reference (same idea as above) on the work pool base job template, and then it would be rendered at runtime
m
@Nate does this work for prefect v2?
n
yes! this works the same in 2 and 3
at least, relatively recent versions of 2.x