ChoiceTransitionOptions Struct
Options for Choice Transition.
Example
ts
import * as events from 'aws-cdk-lib/aws-events';
declare const connection: events.Connection;
const getIssue = tasks.HttpInvoke.jsonata(this, 'Get Issue', {
connection,
apiRoot: "{% 'https://' & $states.input.hostname %}",
apiEndpoint: sfn.TaskInput.fromText("{% 'issues/' & $states.input.issue.id %}"),
method: sfn.TaskInput.fromText('GET'),
// Parse the API call result to object and set to the variables
assign: {
hostname: '{% $states.input.hostname %}',
issue: '{% $parse($states.result.ResponseBody) %}',
},
});
const updateLabels = tasks.HttpInvoke.jsonata(this, 'Update Issue Labels', {
connection,
apiRoot: "{% 'https://' & $states.input.hostname %}",
apiEndpoint: sfn.TaskInput.fromText("{% 'issues/' & $states.input.issue.id & 'labels' %}"),
method: sfn.TaskInput.fromText('POST'),
body: sfn.TaskInput.fromObject({
labels: '{% [$type, $component] %}',
}),
});
const notMatchTitleTemplate = sfn.Pass.jsonata(this, 'Not Match Title Template');
const definition = getIssue
.next(sfn.Choice.jsonata(this, 'Match Title Template?')
// Look at the "title" field of issue in variables using Regex
.when(sfn.Condition.jsonata('{% $contains($issue.title, /(feat)|(fix)|(chore)\(\w*\):.*/) %}'), updateLabels, {
assign: {
type: '{% $match($states.input.title, /(\w*)\((.*)\)/).groups[0] %}',
component: '{% $match($states.input.title, /(\w*)\((.*)\)/).groups[1] %}',
}
})
.otherwise(notMatchTitleTemplate));
new sfn.StateMachine(this, 'StateMachine', {
definitionBody: sfn.DefinitionBody.fromChainable(definition),
timeout: Duration.minutes(5),
comment: 'automate issue labeling state machine',
});
Properties
assign{ [key: string]: any }assigntyping.Mapping[str, Any]assignMap<String, Object>AssignIDictionary<string, object>Assign*map[string]interface{}= Not assign variables#Workflow variables to store in this step.
Using workflow variables, you can store data in a step and retrieve that data in future steps.
An optional description for the choice transition.
outputsanyoutputsAnyoutputsObjectOutputsobjectOutputsinterface{}= $states.result or $states.errorO…#This option for JSONata only.
notes · default
When you use JSONPath, then the state ignores this property. Used to specify and transform output from the state. When specified, the value overrides the state output default. The output field accepts any JSON value (object, array, string, number, boolean, null). Any string value, including those inside objects or arrays, will be evaluated as JSONata if surrounded by {% %} characters. Output also accepts a JSONata expression directly.
Default: $states.result or $states.errorOutput