0

So, I'm working on a state machine. It can have up to 20 or 30 executions of it running at the same time, with different parameters.

One of it's states is an activity worker (needs to wait for some input from another step function execution started from one of it's states through a lambda function, since you can't directly start a new execution from a state machine).

I know how to send a "Task Success" for an activity. But how can I make sure it's sent to the right execution ?

ElFitz
  • 908
  • 1
  • 8
  • 26

2 Answers2

1

Using a pub/sub service such as mqtt would be useful here.

  1. Generate a UUID in the lambda that spawns the new execution.
  2. Pass the UUID to the new execution and return it to the activity worker.
  3. The new execution writes the UUID and result to the queue once it's done.
  4. The activity worker reads from the queue and uses the UUID to find the right message.
Murali Allada
  • 21,718
  • 4
  • 19
  • 21
  • Well, it most certainly is convoluted, but I couldn't do any better any way. Thanks ! – ElFitz Apr 15 '17 at 12:07
  • For future people, you could also use an S3 bucket or DynamoDB for that. Both allow for automated deletion of data for easy cleanup ([DynamoDB Time To Live](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html), [S3 Object Expiration](https://aws.amazon.com/fr/blogs/aws/amazon-s3-object-expiration/)). – ElFitz Aug 29 '18 at 14:39
0

Depending on the design of your state machine, you may also be able to pass the current activity's taskToken as an input parameter when your activity creates a new StepFunction execution. Then the last state in the sub-execution can call Task Success for the state in the parent execution using the taskToken passed in, returning any result data as the results for that state. (Don't forget the last state would also have to call Task Success for itself as well.)

ivo
  • 1,103
  • 10
  • 13