https://prefect.io logo
#prefect-getting-started
Title
# prefect-getting-started
z

Zack

03/08/2023, 10:21 PM
What are the lines that I need for a flow deployment to cloud api server? My first guess is below, but not sure where to put the api key/url. For whatever it's worth, the script will be running in a lambda container.
Copy code
deployment = Deployment.build_from_flow(
flow=artist_ranker_etl,
name="artist-ranker-deployment",
entrypoint="artist_ranker.main.handler",
)
deployment.apply()
1
r

redsquare

03/08/2023, 10:32 PM
two env vars PREFECT_API_KEY and PREFECT_API_URL
👍 1
z

Zack

03/08/2023, 10:42 PM
okay, can these be passed to a prefect function?
j

James Gatter

03/08/2023, 10:51 PM
I believe you don't want to. You just need them in the
env
.
export
each variable and the function will pick it up during runtime. In the case of lambda you could store each in AWS SSM, have the function retrieve them using
boto3
, export them using
os.environ
, then try building and applying your deployment.
👍 1
z

Zack

03/08/2023, 11:19 PM
I haven't used SSM before, but if what you are saying is true then I should be able to simply set them as environment variables under a lambda's configuration settings.
r

redsquare

03/08/2023, 11:34 PM
yup
👍 1
z

Zack

03/09/2023, 12:21 AM
Have any of you come across this error from Deployment.build_from_flow()? [ERROR] JSONDecodeError: Expecting value: line 1 column 1 (char 0) Traceback (most recent call last):
r

redsquare

03/09/2023, 12:25 AM
sounds like an invalid server response, is your api url set correctly
👍 1
z

Zack

03/09/2023, 12:27 AM
hm, checking...
Yep, that was the issue. Wrong format.
👍 2