https://prefect.io logo
s

Sean Talia

02/09/2021, 2:58 PM
i'm trying to use a prefect secret in the most basic way and am having some difficulty...my call
Secret("SECRET_KEY").get()
fails when I try to register my flow:
Copy code
ValueError: Local Secret "SECRET_KEY" was not found.
my backend is set to
cloud
, and I do not have
use_local_secrets = true
set in my config.toml, so I'm not sure why prefect is trying to actually retrieve a local secret there
given how lightweight the documentation on using secrets is, this seems like it should be very straightforward...does one need to explicitly set
use_local_secrets = false
in the config.toml?
a

Amanda Wee

02/09/2021, 3:12 PM
It sounds like it: "For Cloud users, if the secret is not found in local context and
config.cloud.use_local_secrets=False
, the base
Secret
class queries the Prefect Cloud API for a stored secret." So you satisfy the first condition, but without explicitly setting it to false, the second condition is not satisfied.
s

Sean Talia

02/09/2021, 3:13 PM
@Amanda Wee can you link me to where you're reading that? I don't see it on https://docs.prefect.io/orchestration/concepts/secrets.html#using-a-secret – maybe this page of the documentation needs a makeover
ah i see, it's in the core documentation but not the orchestration documentation, thanks for the heads up!
f

Fina Silva-Santisteban

02/10/2021, 12:40 AM
@Sean Talia We’re using prefect cloud too, this is how we’ve been setting secrets:
Copy code
prefect.context.setdefault("secrets",{})
    prefect.context.secrets["EMAIL_USERNAME"] = (SOME_EMAIL)
The first line checks if the
secrets
dictionary already exists, and if it doesn’t, creates it for you. The second one shows you how to add values to it. I hope this helps!