Use switch statements to make decisions based on data from previous steps.
What switch statements enable:
- Create decision trees based on conditions
- Route workflow execution to different steps based on data values
- Evaluate multiple conditions in sequence
- Define default behavior when no conditions match
Conditional logic with data
steps: - name: checkCPU type: action action: newrelic.nerdgraph.execute version: 1 # ... query configuration
- name: decideAction type: switch switch: - condition: "${{ .steps.checkCPU.outputs.data.actor.account.nrql.results[0].average > 90 }}" next: resizeInstance - condition: "${{ .steps.checkCPU.outputs.data.actor.account.nrql.results[0].average > 70 }}" next: sendWarning next: normalOperation
- name: resizeInstance type: action action: aws.ec2.modifyInstanceAttribute version: 1 # ... resize configuration
- name: sendWarning type: action action: slack.chat.postMessage version: 1 # ... warning message
- name: normalOperation type: action action: newrelic.ingest.sendLogs version: 1 # ... log normal statusWhat's next
- Common integrations: Apply patterns to real integrations
- Advanced workflows: Complex decision trees