https://prefect.io logo
#prefect-community
Title
# prefect-community
a

Alexander Belikov

04/14/2022, 5:39 PM
Hi I have a question regarding scheduling prefect flows with parameters, I think I'm missing something simple : how do you pass db creds, if not through parameters (without hard-coding passwords, paths, etc)? I've posted my questions on SO: https://stackoverflow.com/questions/71875658/running-registering-prefect-flows-with-parameters-on-schedule, please let me know what you think. thanks!
here in this example : https://stackoverflow.com/questions/70328855/how-to-organize-prefect-flow-with-the-using-of-cmd-arguments @Anna Geller is suggesting a parameterized
run
but then to register it without parameters... This example essentially emulates my case
a

Anna Geller

04/14/2022, 5:47 PM
are you on Prefect Cloud or Server? generally speaking, a parameter task is not a good way of passing Secrets such as DB credentials - if you are on Prefect Cloud, you may leverage the Secret backend to store these securely. If you are on Server, you could leverage some external Secrets Manager and retrieve those from within your task when needed
k

Kevin Kho

04/14/2022, 5:47 PM
Couple of things: 1. DB creds should ideally be secrets instead of parameters. On Prefect Cloud, you can store the secret with us and load it using the
PrefectSecret
task. On Server, you need to store local secrets. You can also see more on that here 2. On the parameters, you can also do
required=False
so that you can register without a default 3. Parameters defaults on clocks/schedule don’t fulfill the requirement of having a default parameter because you can still trigger ad-hoc runs that would then not have any filled value.
👍 2
Also, no need to crosspost btw between StackOverflow and here. Although, it’s actually good for us so we don’t mind. But we get notified as well with StackOverflow if you use the
prefect
tag
upvote 1
a

Alexander Belikov

04/15/2022, 10:19 AM
sounds good - I'll keep posting on StackOverflow since it might help wider audience. My takehomes are : 1) use secrets for creds, 2) hard-code other flow parameters using clocks (as in https://docs.prefect.io/core/concepts/schedules.html#clocks) 3) Not sure about
required=False
- I want to be able to register and schedule flows with parameters that are required
a

Anna Geller

04/15/2022, 10:25 AM
sounds good - I'll keep posting on StackOverflow since it might help wider audience.
Actually, could you post to Discourse instead? This is our preferred platform
1
#2 hard-code sounds so bad 😄 those are really just default parameter values. You can always override those from the UI or for a specific run via UI/API/CLI #3 required is useful if you always want to have some values - this post dives much deeper into the topic if you're interested
a

Alexander Belikov

04/15/2022, 1:14 PM
yes, hard-coding is bad practice 🙂 thank you for sharing this post I haven't seen it before
k

Kevin Kho

04/15/2022, 1:39 PM
I don’t think the flow parameter on the clock lets you register a Flow that has a required parameter with no default. Because there is still a scenario where you can trigger an ad-hoc run outside a schedule and the parameter isn’t supplied.
upvote 1
5 Views