We created step function (WAIT State) to execute schedule task based up on user input time.
We are calling this step up function from PHP code so it will create entry in that state machine and step function (WAIT State) will trigger lambda service automatically when it meets countdown timer.
My requirement is to user to have the option to update the time or cancel event from PHP application. at this scenario i have to update existing scheduled step function event/task time to new time or delete the existing scheduled event and create new scheduled event with latest time.
How can i do with this from PHP application?
The below is my PHP code to create event in AWS step function.
$inputData = '{'.'"invocationTime"'. " : " .'"'.'2022-10-28T13:15:16Z.'"'.','.'"userid"'. " : " .'"1233345"'.'}';
$data = array(
//This is the schedule in UTC time.
'input' => $inputData,
'name' => 'Test Charan",
//STATIC
'stateMachineArn' => $awsDataarn //AWS stateMachineArn
);
$inputdataaws = array(
'http' => array(
'method' => 'POST',
'content' => json_encode($data),
'header' => "x-api-key: ".$awsDataapiKey."rn".
"Content-Type: application/jsonrn"
)
);
$url = 'https://testcharan.execute-api.us-east-1.amazonaws.com/myapplication/scheduletask'; //AWS endpoint URL
$request = stream_context_create($inputdataaws); // TO create data in AWS statemachine
$result = file_get_contents($url, false, $request); //read the data
$response = json_decode($result); //decode the result
The above code will create the event in AWS step function.
How i can update or delete or abort events/execution those or on Running status?
2
Answers
you can’t modify a state machine directly on runtime (on my experiece).
I suggest to
How to stop all running Step Functions of a specific state machine?
It is likely that your use-case could benefit from the callback pattern which will cause your state machine execution to wait for an event for the
$$.Task.Token
to be received. You can set a timeout by providing aHeartbeatSeconds
which will cause the task to fail withStates.Timeout
.