Hi Everyone!! I have been experimenting with prefe...
# ask-community
v
Hi Everyone!! I have been experimenting with prefect lately and wanted to know if there is anything similar to s3 sensors in prefect. I want to trigger my flow or make my tasks wait/run until there is a file/files being uploaded in the s3 buckets
k
Hey @Vamsi Reddy, there isn’t one but you can do it the other way around where the s3 bucket triggers a lambda that creates a flow. Otherwise you would need to just poll inside your task to determine if there was a change in the bucket
v
Thanks for the info @Kevin Kho. Also are there any tutorials for this ?
k
Not really but the StartFlowRun task has a polling mechanism. It’s just a loop
c
this isn't quite a tutorial (and is a little old) but does show some code for the lambda that is still relevant: https://medium.com/the-prefect-blog/event-driven-workflows-with-aws-lambda-2ef9d8cc8f1a
a
@Vamsi Reddy while lambda is the cleanest option, if you don't want to implement AWS Lambda with trigger, boto3 also has waiter abstraction that allows your code to wait until the file arrived - you could build something like this into your Prefect task (only the last 2 lines are interesting):
upvote 2