Cade Summers
09/22/2025, 5:07 PMMarvin
09/22/2025, 5:07 PMMarvin
09/22/2025, 5:11 PM.get()
when you have access.
Example copy script (handle carefully; don’t log secrets):
from prefect.blocks.system import Secret
from prefect.settings import temporary_settings, PREFECT_API_URL, PREFECT_API_KEY
# Fill in your API URLs/keys for each workspace
PROD = {
PREFECT_API_URL: "<https://api.prefect.cloud/api/accounts/<account_id>/workspaces/<prod_workspace_id>>",
PREFECT_API_KEY: "<prod_api_key>",
}
DEV = {
PREFECT_API_URL: "<https://api.prefect.cloud/api/accounts/<account_id>/workspaces/<dev_workspace_id>>",
PREFECT_API_KEY: "<dev_api_key>",
}
# List the secret block names you want to copy
secret_names = ["db-password", "slack-token"]
# Read from prod
with temporary_settings(PROD):
values = {name: Secret.load(name).get() for name in secret_names}
# Write to dev (creates or updates)
with temporary_settings(DEV):
for name, value in values.items():
Secret(value=value).save(name, overwrite=True)
Helpful tips:
- You can list what blocks exist in a workspace with:
prefect block ls
- Inspect an individual block (metadata only; not the secret value):
prefect block inspect -n <block-name>
- Keep block names consistent across environments so your code can always Secret.load("<name>")
.
Docs:
- Workspaces overview: Workspaces in Prefect Cloud
- Storing and using secrets: Store secrets with Secret blocks
If you’d like, tell me how many secrets you need to copy and I can tailor a script (e.g., discover all Secret blocks in prod and mirror them to dev).