Blueprints

Microservice orchestration: invoke multiple AWS Lambda functions in parallel

Source

yaml
id: aws-lambda
namespace: company.team

tasks:
  - id: parallel
    type: io.kestra.plugin.core.flow.Parallel
    tasks:
      - id: lambda
        type: io.kestra.plugin.aws.lambda.Invoke
        functionArn: arn:aws:lambda:eu-central-1:123456789:function:demo

      - id: lambda_version
        type: io.kestra.plugin.aws.lambda.Invoke
        functionArn: arn:aws:lambda:eu-central-1:123456789:function:ResultHandler:1
        functionPayload:
          your_event_input: hello

      - id: lambda_alias
        type: io.kestra.plugin.aws.lambda.Invoke
        functionArn: arn:aws:lambda:eu-central-1:123456789:function:ResultHandler:kestra
        functionPayload:
          your_event_input: hey there

  - id: lambda_result
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.core.runner.Process
    commands:
      - cat {{ outputs.lambda.uri }} | jq -r '.body'

About this blueprint

AWS Serverless

This flow invokes multiple AWS lambda functions in parallel. It demonstrates how you can:

  1. Invoke a Lambda function based on its ARN, including invoking a specific version or alias of your function 2. Easily pass custom functionPayload in a simple dictionary format 3. Access the output of the Lambda result JSON payload and extract relevant data using jq To test this blueprint, you can create a simple function, e.g. in Python, named demo as follows:
python
def lambda_handler(event, context):
    print(event)
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

And another one named ResultHandler:

python
def lambda_handler(event, context):
    function_result = event['your_event_input']
    return {
        'body': json.dumps(function_result + ' from Kestra')
    }

You can then create a custom version or alias for your function, if needed.

Parallel

Invoke

Commands

Process

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra