Hi, I am new to Prefect. Prefect cloud login comma...
# prefect-cloud
a
Hi, I am new to Prefect. Prefect cloud login command is failing with ssl error in ubuntu
1
m
Hey @Anjaneyulu K Are you running prefect 1 or prefect 2
a
Prefect2
m
What error are you seeing when this fails, is this command running as part of a build process for an image is are you running this within a terminal?
a
ssl.SSLerror unsafe legacy renegotiation disabled
When I am trying to connect local flow to prefect cloud using prefect cloud ligin -k <apikey>
👀 1
Direct command from terminal
k
Do you have specific firewall rules that could be restricting the request to the Prefect Api?
m
Also if you run prefect version what output do you see?
a
Version: 2.6.5
Strange. I have intalled 2.3.1
Not sure how it is updated
And coming to firewall. I have no restrictions for now. If its there how to handle
no option to pass ssl certficates
m
Do you run into the same error if you remove and reinstall prefect?
a
I dint try with reinstall
let me try
m
worst case you can also try setting the PREFECT_CLOUD_API_URL and PREFECT_CLOUD_API_KEY with
prefect config set
This is technically what the prefect cloud login command is doing as well
j
What version of Ubuntu are you running? You can see in
/etc/os-release
a
22.04.01 LTS
I have tried reinstall same error
where can I find prefect cloud url from UI
m
The URL should be in this format
"<https://api.prefect.cloud/api/accounts/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/workspaces/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>"
you can get both the account and workspace ID from the URL the cloud page. this covers a basic example https://discourse.prefect.io/t/prefect-1-0-prefect-2-0-user-configurations-to-configuration-profiles/1299. it might also be helpful to set the prefect logging level to debug in the configuration as well, you can see all available config values with this command
prefect config view --show-all
a
Not able to figure out account Id. Got workspace ID
m
Both the Account Id and Workspace ID should be populated in the URL when you've accessed a workspace https://app.prefect.cloud/account/ACCOUNT_ID/workspace/WORKSPACE_ID/
a
Now I got it. You mean address bar.
m
Yep 😄
a
Copy code
PREFECT_API_URL
or prefect_cloud_api_url ?
which one i need to use
or both are same
m
PREFECT_API_URL
and
PREFECT_API_KEY
should be all you need to set to connect to cloud, I am curious if you'll get the same error in this format if you do if may be worth resetting the db
Copy code
rm -rf ~/.prefect/orion.db && prefect orion database reset -y
a
After setting up values I ran the program but I cant see that deployment in prefect cloud
I ran prefect orion start and end up with same error
SSL unsafe legacy renegotiation
unsafe legacy renegotiation disabled
with none values I can see at orion server
m
That would make sense, Prefect Cloud is the SaaS offering from us where as orion is available for self-hosting, are you wanting to utilize prefect cloud or were you wanting to self-host Orion and manage you're workflows there?
a
prefect cloud
getting same error
Is SSL error expected
m
I wouldn't say expected but it sounds like maybe we might want to start with the basics here https://docs.prefect.io/getting-started/overview/#get-started-with-prefect-2, for running your flows through through an ec2 instance this is a good resource to start with https://discourse.prefect.io/t/how-to-build-a-prefect-2-0-poc-on-aws/1066
we also have some recipes available here that may be helpful in getting started https://github.com/PrefectHQ/prefect-recipes
a
I am following the same steps . but prefect cloud dashboard connection making some issue
I will double check the steps. Thank you. I will come back to you
What would be the prefect2 stable version
m
I'm not sure what you mean by stable version, 2.6.6 is the most recent version but several previous versions are stable as well, for clarities sake are you trying to get an agent setup on your ec2 instance to run your flows?
Mostly the differences are going to be in what features are available
Would you be willing to outline your use case a bit more, I might be able to off some more specific guidance there? I'll also note If you're wanting to utilize prefect cloud you won't need to start prefect Orion at any point, you're likely wanting to setup an Agent that can pick up your deployed workflows from prefect cloud
a
Its pretty straight forward. I want deploy aws glue jobs using Prefect and utilize prefect cloud dashboard.
Here installing prefect on ec2 means agent only right
Or Am I missing something
Also I want to do deployments env specific like dev, test
k
There's a couple ways you can accomplish this. A flow can have multiple deployments. A deployment is associated with a work queue. So you could have two different work queues (each work queue is directly tied to one agent and agent's are where your execution is). You can also have tags which allow you to filter on the Flow Runs dashboard. Another way to accomplish this would be to use workspaces in Prefect Cloud. Each workspace can separate out the flows, blocks, work queues, agents, and deployments.
I recommend checking out this full demo video that walks through fundamental pieces of Prefect; deployments, agents, work queues, blocks, and navigating the Prefect Cloud UI.

https://www.youtube.com/watch?v=AI-Ks5x7Mp4

a
Quick question here: Suppose my deployments scheduled for every 1 hour. So If I dont run command prefect agent start --work-queue "name" flows wont be executed
k
Correct. Deployments will allow flows to be scheduled but without an agent, there is nothing querying for those flow runs. If the agent isn't running, the scheduled flow run will go into a "Late" state and will wait until the agent is back online to pick up the work.
a
how to include prefect agent start as part of code and not running like separate command. Or how to keep agent active to avoid late state
As soon as schedule time comes agent should become active/online automatically. Can we do that
May be we need to start agent on time trigger bases. Correct me if I am wrong
k
Great question. We have recipes for spinning up the agent on ECS so that the agent is always running. https://github.com/PrefectHQ/prefect-recipes/tree/main/devops/infrastructure-as-code/aws/tf-prefect2-ecs-agent You might also want to check out our discourse which has lots of topics and how-to's such as this guide for serverless and ecs. https://discourse.prefect.io/t/serverless-real-time-data-pipelines-on-aws-with-prefect-ecs-and-github-actions-blog-post-by-anna-geller/1240
a
Cool, I will go through them
One more question: In case of AWS Can we use lambda function to trigger prefect agent instead of keeping active always with ECS to avoid cost
k
Definitely! In fact, you can even trigger flow code directly from the lambda in which case you would not even need an Agent or Deployment. I believe that serverless guide walks through that option and even has sample code to do that 😄
a
Great. Thank you for your patience. Appreciated:)
So much learnt today on prefect. Need to do some practice and come back with bag of Questions 😜
Night Night