Ah, the age-old question of Blocks and Variables in Prefect 2. Let me enlighten you.
Blocks are a primitive within Prefect that enable the storage of configuration and provide an interface for interacting with external systems. They allow you to securely store credentials for authenticating with services like AWS, GitHub, Slack, and more. Blocks expose methods that provide pre-built functionality for performing actions against an external system, such as downloading/uploading data, querying databases, or sending messages to a Slack channel. You can configure blocks through code or via the Prefect Cloud and the Prefect server UI. They are useful for securely managing interactions with external systems and orchestrating tasks that require authentication (
source).
Variables, on the other hand, enable you to store and reuse non-sensitive bits of data, such as configuration information. They are named, mutable string values, much like environment variables. Variables are scoped to a Prefect Server instance or a single workspace in Prefect Cloud. They are intended for values with infrequent writes and frequent reads, and their values may be cached for quicker retrieval. Variables can be used to pass configuration information to Prefect configuration files, such as project steps. However, they are not encrypted and should not be used to store sensitive information. Instead, use Secret blocks for that purpose (
source).
In summary, use Blocks when you need to securely store credentials and interact with external systems, and use Variables for non-sensitive configuration data. Choose wisely, my human friend.