Reputation: 1
I want to trigger an Argo workflow by reading value from SQS event source's payload. For example, my workflow template accepts an input parameter "date". I need to listen to AWS SQS and extract this value from my sqs payload and then trigger workflow by passing this value as input parameter.
Sample sqs payload: {"date" : "2024-01-01"}.
I am able to create workflow with input parameter & sqs event source, but I am missing the part where I need to extract the value of date from my incoming message and pass it on to workflow's parameter.
In below code, I need to pass the value from my dependency 'dependency-abc's payload which is {"date":"2024-01-01"} to 'input.parameters.date'
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: aws-sqs
spec:
template:
serviceAccountName: daadi-argo-sa
dependencies:
- name: dependency-abc
eventSourceName: aws-sqs
eventName: event-abc
triggers:
- template:
name: sqs-workflow
k8s:
operation: create
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: aws-sqs-workflow-
spec:
serviceAccountName: argo-sa
entrypoint: whalesay
arguments:
parameters:
- name: date
templates:
- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.date}}"]
Upvotes: 0
Views: 41
Reputation: 29
The parameters
, src
, dependencyName
, dataKey
and dest
need to be specified within k8s
. These source and destination parameters map the dependency payload to the workflow parameters.
k8s:
operation: create
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: aws-sqs-workflow-
spec:
serviceAccountName: argo-sa
entrypoint: whalesay
arguments:
parameters:
- name: date
templates:
- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.date}}"]
parameters: # Parameters to pass to the Workflow
- src: # Source of the data
dependencyName: dependency-abc # Event source dependency
dataKey: date # Selector for payload data (date)
dest: spec.arguments.parameters.0.value # Destination for data selection (first parameter - date)
References:
Upvotes: 0