<p>One approach is to invoke a Lambda function within the Step Function and coordinate between the Step Function and EventBridge.</p>
<p>Another idea is to separate the process into two Step Functions. This way, you can execute the second part of the tasks directly through an EventBridge event by setting the second Step Function as a target in the EventBridge rule.</p>
<p>This separation allows for better management and efficiency, ensuring the replication task only starts once the ReplicationInstance is active.</p>

CC BY-SA 4.0
2024-07-06T12:27:58.653Z
2024-07-06T19:00:43.897Z
2024-07-06T19:00:43.897Z
Santiago
<p>I have a use case where I manually trigger an AWS Step Function to migrate data between two different databases using the AWS DMS service. The Step Function execution creates a resource called ReplicationInstance. The problem is that the creation of the ReplicationInstance takes more than 18 minutes. Currently, I'm using an estimated wait time of 20 minutes, but this is not efficient.</p>
<p>I want to improve this process by pausing the creation of the replication task until the ReplicationInstance is successfully created. To achieve this, I'm using an EventBridge rule to detect when the ReplicationInstance status becomes active. My goal is to automate the process of capturing the task token from the Step Function and sending it back when the event &quot;ReplicationInstance is active&quot; is triggered.</p>
<p>The figure below illustrates the problem I'm facing.
<a href="https://i.sstatic.net/CbUgfzBr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CbUgfzBr.png" alt="enter image description here" /></a>
Can anyone provide guidance or examples on how to automate the task token capture and return process within AWS Step Functions?</p>

<amazon-web-services><step-functions>
AWS Step Function - Stop function until TaskToken is back
zonix devWeb
# AWS Step Function - Stop function until TaskToken is back

(Asked by: username_0 on 2024-07-06)

I have a use case where I manually trigger an AWS Step Function to migrate data between two different databases using the AWS DMS service. The Step Function execution creates a resource called ReplicationInstance. The problem is that the creation of the ReplicationInstance takes more than 18 minutes. Currently, I'm using an estimated wait time of 20 minutes, but this is not efficient.

I want to improve this process by pausing the creation of the replication task until the ReplicationInstance is successfully created. To achieve this, I'm using an EventBridge rule to detect when the ReplicationInstance status becomes active. My goal is to automate the process of capturing the task token from the Step Function and sending it back when the event "ReplicationInstance is active" is triggered.

The figure below illustrates the problem I'm facing.
[![enter image description here](https://i.sstatic.net/CbUgfzBr.png)](https://i.sstatic.net/CbUgfzBr.png)
Can anyone provide guidance or examples on how to automate the task token capture and return process within AWS Step Functions?

**Tags:** amazon-web-services, step-functions


---

## 1 answers

### Answer by username_1 on 2024-07-06. Score: 0 | Accepted answer

One approach is to invoke a Lambda function within the Step Function and coordinate between the Step Function and EventBridge.

Another idea is to separate the process into two Step Functions. This way, you can execute the second part of the tasks directly through an EventBridge event by setting the second Step Function as a target in the EventBridge rule.

This separation allows for better management and efficiency, ensuring the replication task only starts once the ReplicationInstance is active.


---

