Jakub Vedral
01/29/2021, 8:20 AMAmanda Wee
01/29/2021, 8:40 AMSLACK_WEBHOOK_URL
secret, and did so by setting a PREFECT__CONTEXT__SECRETS__SLACK_WEBHOOK_URL
environment variable on the Docker container (to be used in ECS, but also for local testing) running the prefect local agent, and it worked. I was also able to check the secret like this:
def slack_notifications_enabled() -> bool:
"""Return True if Slack notifications are enabled."""
slack_webhook_url = Secret("SLACK_WEBHOOK_URL")
return slack_webhook_url.exists()
and use the above code to decide whether or not to set a state handler on the flow (so I can run the flow locally without sending a Slack notification).
The prefect server setup was not provided with the secret.Jakub Vedral
01/29/2021, 8:46 AMAmanda Wee
01/29/2021, 8:59 AMprefect agent local start
if you are going to access it within the flow.
I think using the config file might work too, but I have not tried it.
I did not set it before the start of the prefect server, but rather after they were started.Jakub Vedral
01/29/2021, 9:36 AMJeremiah
01/29/2021, 2:06 PMJakub Vedral
01/29/2021, 3:14 PMclient.set_secret(name="my secret", value=42)
?
I guess GraphQL option is only for the Cloud version aswell.
I was wondering if setting them as ENV variables on agent (using the --env flag) is the way to keep them persistent and share them among several flows.Jeremiah
01/29/2021, 3:17 PMclient.set_secret
is calling Prefect Cloud’s secret manager API, so it won’t work with Prefect Server. However, setting env vars is a good way to configure and provide information to any flow run launched by that agentJakub Vedral
01/30/2021, 8:48 AM