https://prefect.io logo
Title
s

Stéphan Taljaard

05/16/2023, 4:45 PM
Can you give a use-case example of Blocks vs Variables?
1
c

Christopher Boyd

05/16/2023, 4:47 PM
They are very similar in general; an example that I have used, are static API urls for a 3rd party api. There are routine messages sent in a flow to this 3rd party api (jira) , but I have different api URLS between tiers (dev / stage / prod) . I use the same code in the flow to reference the same named variable, but different values across workspaces
e.g., dev might be:
https:/dev.jira.com
then
<https://stage.jira.com>
where the flow code references just a single name variable
then if it changes, I can just change it in a single location
s

Stéphan Taljaard

05/16/2023, 4:48 PM
Blocks are preferred over Variables for storing sensitive information, right?
c

Christopher Boyd

05/16/2023, 4:48 PM
yes, specifically SecretStr which are intentionally obfuscated
🙌 2
An alternate mechanism is using a JSON block to store a reference / location to a secret in your existing secrets manager like AWS / Azure Keyvault
:its-beautiful: 1
you can defer the secrets that way, but that requires a little more hand-written code to access
using like identity