(triggers): start/wait for a step functions state machine
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Description
I'd like a [triggers](https://github.com/aws/aws-cdk/tree/master/packages/%40aws-cdk/triggers) feature that starts and monitors a long-running Step Function state machine until the state machine is done.
### Use Case
We encode slow, often orchestration-based, integration tests into Step Functions State Machines. We currently run some of these state machines via custom resources so that deployments can back out automatically when the tests fail.
In theory, we could write and use a custom lambda with `TriggerFunction` to start and monitor a state machine. But when the state machine takes greater than fifteen minutes to run, the triggered function will hit the lambda execution time limit while monitoring a long-running state machine.
### Proposed Solution
```ts
import * as triggers from '@aws-cdk/triggers';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import { Stack } from '@aws-cdk/core';
declare const stack: Stack;
declare const stateMachine: sfn.StateMachine;
new triggers.TriggerStateMachine(stack, 'MyTrigger', {
stateMachine,
});
```
Perhaps the custom resource provider could start the provided state machine and use the same trick as the cr provider framework's `isComplete` feature to poll the status of the execution until it encounters a terminal state. Once the provider has detected a terminal state, the CR can succeed or error out with a description from the execution history's failed/aborted/timeout event.
### Other information
_No response_
### Acknowledge
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
Contributor guide
Research direction
Start in packages/@aws-cdk/triggers and read the existing TriggerFunction entry point, then inspect the custom resource provider framework's isComplete polling behavior. Define how TriggerStateMachine starts and monitors the provided state machine, succeeds on a terminal success, and reports failed, aborted, or timed-out executions; validate the behavior with the project's relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100