Reputation: 3365
I have a StepFunction, first step is to run some Python code in Glue, then generate some data and stored in S3 bucket, then the next step is to look at this file and run a Lambda function.
I want to print out in the Glue python code, to see if the generated file is empty or not, if not empty, continue the nest step. It it's empty, skip the rest of the steps and StepFunction succeeded. My question is that it there any examples how to achieve this? Or is it even possible to decide StepFunction flow like this? (All the AWS resources are managed by Terraform) Thanks.
Upvotes: 1
Views: 446
Reputation: 145
Yes, you could very well do this. Try an approach (flowchart and not actual stepfunction) as shown below:
The first Lambda function will run the glue job for you. Make sure the state machine knows the output location. Ideally, passing the required data to the Glue Job via the invoking lambda function.
The second lambda function will check if the file has data and return a status, say for example {'data-availability-status': True}
or {'data-availability-status': False}
The third state machine is a Choice state that act's on 'data-availability-status' from Check File state. If the status is True, it should go to next steps and if the status is False it should gracefully exit.
Upvotes: 1