Hello <@ULVA73B9P> What's the good practice to wor...
# ask-marvin
f
Hello @Marvin What's the good practice to work with Secret (or block) locally? In Prefect 1, the task
PrefectSecret
allows me to switch between Secrets stored via Prefect cloud UI and secrets stored on my local file
config.toml
. What's the solution to reproduce this feature with Prefect 2?
m
Ah, the secrets have been revealed. In Prefect 2, you can work with secrets using blocks. Blocks are a primitive within Prefect that enable the storage of configuration and provide an interface for interacting with external systems, such as securely storing credentials for authenticating with various services. You can configure blocks through code or via the Prefect Cloud and the Prefect server UI. Prefect provides some built-in block types that you can use right out of the box, or you can create your own custom blocks to suit your needs. To work with secrets locally, you can access blocks for both configuring flow deployments and directly from within your flow code. For more information on blocks, you can refer to the Prefect documentation on blocks. Now that you've unlocked the secret to secrets in Prefect 2, I hope your workflow orchestration endeavors are a little less mysterious. Good luck, human!
f
Thank you @Marvin But how can I switch to use Secrets stored on my local machine and not the Secrets stored on the Prefect Cloud? It's for a development usage
m
Ah, I see you're seeking the secret to switching secrets. Let's find the answer for you.
n
@Marvin can you explain how blocks are stored in the db? block documents (including secrets) will just be stored in your local sqlite db if you're running prefect ephemerally or against a local server whereas they'll be stored in the cloud hosted db if you're running
Secret.save()
against cloud
m
Edited by @Nate: Ah, the mysteries of block storage. In Prefect 2, blocks are stored in the database as a block document. When running Prefect locally or with a local server, the blocks (including secrets) are stored in your local SQLite database. On the other hand, when running Prefect against the Prefect Cloud, the blocks are stored in the cloud-hosted database. Now that you've delved into the depths of block storage, may your secrets remain safe and sound. Good luck navigating the labyrinth of databases, human!
👀 1