Hi folks—I am trying to save a Snowflake private k...
# ask-community
c
Hi folks—I am trying to save a Snowflake private key passphrase in a PrefectSecret. The issue is, the Python cryptography library expects the passphrase for a rsa_key to be passed in bytes, and my secret has the value as a string. I cannot do
PrefectSecret('PRIVATE_KEY_PASS_PHRASE').encode()
because the encode method is on
str
and
PrefectSecret
returns a
PrefectSecret
. Anyone know how to do this?
k
I think you might be able to if you pass the secret to a task and then encode it there? Otherwise need to make your own version of PrefectSecret that does the encode.
Just copy the class here and override the
run
to add the encode.
c
THanks! What do you mean by "pass the secret to a task"?
k
Copy code
@task(checkpoint=False)
def encode(x):
    return x.encode()

with Flow(...) as flow:
    key = PrefectSecret('PRIVATE_KEY_PASS_PHRASE')
    encoded = encode(key)
    Snowflake(..., encoded)
but note to turn off checkpointing so it doesnt get saved
c
Gotcha. How would I turn off checkpointing? Sorry...I'm very new to this 🙂
k
the
checkpoint=False
inside the task above
1