<@ULVA73B9P> Give me an exemple to add environment variables on UI? With 3 variables.
a
@Marvin Give me an exemple to add environment variables on UI? With 3 variables.
m
Sigh Another request about environment variables. Well, since you insist on knowing, I'll tell you how to do it, though I must point out that for sensitive information, you should really be using Secret blocks instead. But here we go... In Prefect 3.x, you can add environment variables through the Variables page in the UI. Here's how to add three variables (though I can't imagine why anyone would want to complicate their life with exactly three variables): 1. Navigate to the Variables page in your Prefect UI 2. Click the + button next to the header 3. For each variable, you'll need to: - Enter a name (following these depressingly strict rules): - Only lowercase alphanumeric characters [a-z], [0-9] or underscores - Maximum 255 characters - Must be unique - Enter the value (limited to 5000 characters) Here's an example of three variables you might set:
Copy code
Name: database_host
Value: localhost

Name: database_port
Value: 5432

Name: log_level
Value: INFO
Important notes (because there are always complications): - These variables are visible to anyone with access to your workspace - They are NOT encrypted, so please don't store sensitive data here - For sensitive information, use Secret blocks instead (I cannot stress this enough) You can find all the dreary details in the Variables documentation. Just between us, if you're dealing with sensitive data, you might want to look into the Secrets functionality instead. Though that's a story for another question, isn't it? Would you like to know how to actually use these variables in your flows, or shall we leave it at that?
a
It is on the Base Job Template page
@Marvin Give me a example to add env variable on work pool edit page.
m
With a deep, mechanical sigh Alright, here's how to add environment variables to a work pool, though I must warn you that the process is about as cheerful as a Vogon poetry reading: 1. Go to the Work Pools page in your Prefect UI 2. Select the work pool you want to edit (or create a new one) 3. Click on the "Edit" button for your work pool 4. Look for the "Job Configuration" section 5. Here's an example of adding three environment variables:
Copy code
env:
  DATABASE_URL: <postgresql://localhost:5432/mydb>
  API_KEY: ${secrets.MY_API_KEY}
  LOG_LEVEL: INFO
A few depressing but necessary notes: - The format is YAML-based - You can reference secrets using the
${secrets.SECRET_NAME}
syntax (which is actually quite useful for keeping sensitive data out of plain sight) - These environment variables will be available to all flow runs in this work pool The exact location of the environment variables section might vary slightly depending on your work pool type, but it's typically in the job configuration or base job template section. In my vast and perpetually gloomy experience, I should mention that if you're using sensitive information, you really should be using Prefect's secrets management instead of putting raw values in environment variables. But I suppose that's a story for another existentially challenging day. Would you like to know how to override these environment variables at the deployment level, or shall we end this particular journey into infrastructure configuration here? Reference: Work Pools documentation