# LambdaInvokeJsonataProps

Properties for invoking a Lambda function with LambdaInvoke using Jsonata.

Extends: [TaskStateJsonataBaseProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.TaskStateJsonataBaseProps.html)
Used as argument in: [LambdaInvoke.jsonata](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.LambdaInvoke.html#jsonata)

- Source: [`aws-stepfunctions-tasks/lib/lambda/invoke.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-stepfunctions-tasks/lib/lambda/invoke.ts#L84)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

TypeScript:

```ts
import * as lambda from 'aws-cdk-lib/aws-lambda';

declare const callApiFunc: lambda.Function;
declare const useVariableFunc: lambda.Function;
const step1 = tasks.LambdaInvoke.jsonata(this, 'Step 1', {
  lambdaFunction: callApiFunc,
  assign: {
    x: '{% $states.result.Payload.x %}', // JSONata
    // x: sfn.JsonPath.stringAt('$.Payload.x'), // When use JSONPath
  },
});
const step2 = sfn.Pass.jsonata(this, 'Step 2');
const step3 = sfn.Pass.jsonata(this, 'Step 3');
const step4 = sfn.Pass.jsonata(this, 'Step 4');
const step5 = tasks.LambdaInvoke.jsonata(this, 'Step 5', {
  lambdaFunction: useVariableFunc,
  payload: sfn.TaskInput.fromObject({
    x: '{% $x %}',  // JSONata
    // x: sfn.JsonPath.stringAt('$x'), // When use JSONPath
  }),
});
```

Python:

```python
import aws_cdk.aws_lambda as lambda_

# call_api_func: lambda.Function
# use_variable_func: lambda.Function

step1 = tasks.LambdaInvoke.jsonata(self, "Step 1",
    lambda_function=call_api_func,
    assign={
        "x": "{% $states.result.Payload.x %}"
    }
)
step2 = sfn.Pass.jsonata(self, "Step 2")
step3 = sfn.Pass.jsonata(self, "Step 3")
step4 = sfn.Pass.jsonata(self, "Step 4")
step5 = tasks.LambdaInvoke.jsonata(self, "Step 5",
    lambda_function=use_variable_func,
    payload=sfn.TaskInput.from_object({
        "x": "{% $x %}"
    })
)
```

Java:

```java
import software.amazon.awscdk.services.lambda.*;

Function callApiFunc;
Function useVariableFunc;

LambdaInvoke step1 = LambdaInvoke.jsonata(this, "Step 1", LambdaInvokeJsonataProps.builder()
        .lambdaFunction(callApiFunc)
        .assign(Map.of(
                "x", "{% $states.result.Payload.x %}"))
        .build());
Pass step2 = Pass.jsonata(this, "Step 2");
Pass step3 = Pass.jsonata(this, "Step 3");
Pass step4 = Pass.jsonata(this, "Step 4");
LambdaInvoke step5 = LambdaInvoke.jsonata(this, "Step 5", LambdaInvokeJsonataProps.builder()
        .lambdaFunction(useVariableFunc)
        .payload(TaskInput.fromObject(Map.of(
                "x", "{% $x %}")))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;

Function callApiFunc;
Function useVariableFunc;

var step1 = LambdaInvoke.Jsonata(this, "Step 1", new LambdaInvokeJsonataProps {
    LambdaFunction = callApiFunc,
    Assign = new Dictionary<string, object> {
        { "x", "{% $states.result.Payload.x %}" }
    }
});
var step2 = Pass.Jsonata(this, "Step 2");
var step3 = Pass.Jsonata(this, "Step 3");
var step4 = Pass.Jsonata(this, "Step 4");
var step5 = LambdaInvoke.Jsonata(this, "Step 5", new LambdaInvokeJsonataProps {
    LambdaFunction = useVariableFunc,
    Payload = TaskInput.FromObject(new Dictionary<string, object> {
        { "x", "{% $x %}" }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"

var callApiFunc Function
var useVariableFunc Function

step1 := tasks.LambdaInvoke_Jsonata(this, jsii.String("Step 1"), &LambdaInvokeJsonataProps{
	LambdaFunction: callApiFunc,
	Assign: map[string]interface{}{
		"x": jsii.String("{% $states.result.Payload.x %}"),
	},
})
step2 := sfn.Pass_Jsonata(this, jsii.String("Step 2"))
step3 := sfn.Pass_Jsonata(this, jsii.String("Step 3"))
step4 := sfn.Pass_Jsonata(this, jsii.String("Step 4"))
step5 := tasks.LambdaInvoke_Jsonata(this, jsii.String("Step 5"), &LambdaInvokeJsonataProps{
	LambdaFunction: useVariableFunc,
	Payload: sfn.TaskInput_FromObject(map[string]interface{}{
		"x": jsii.String("{% $x %}"),
	}),
})
```

## Properties

- `assign`: { [key: string]: any } — Workflow variables to store in this step.

  **Default:** Not assign variables

  Using workflow variables, you can store data in a step and retrieve that data in future steps.

- `clientContext`: string — Up to 3583 bytes of base64-encoded data about the invoking client to pass to the function.

  **Default:** No context

- `comment`: string — A comment describing this state.

  **Default:** No comment

- `credentials`: [Credentials](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Credentials.html) — Credentials for an IAM Role that the State Machine assumes for executing the task.

  **Default:** None (Task is executed using the State Machine's execution role)

  This enables cross-account resource invocations.

- `heartbeat`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — use `heartbeatTimeout`

- `heartbeatTimeout`: [Timeout](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Timeout.html) = None — Timeout for the heartbeat.

  [disable-awslint:duration-prop-type] is needed because all props interface in
  aws-stepfunctions-tasks extend this interface

- `integrationPattern`: [IntegrationPattern](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.IntegrationPattern.html) — AWS Step Functions integrates with services directly in the Amazon States Language.

  **Default:** `IntegrationPattern.REQUEST_RESPONSE` for most tasks. `IntegrationPattern.RUN_JOB` for the following exceptions: `BatchSubmitJob`, `EmrAddStep`, `EmrCreateCluster`, `EmrTerminationCluster`, and `EmrContainersStartJobRun`.

  You can control these AWS services using service integration patterns.

  Depending on the AWS Service, the Service Integration Pattern availability will vary.

- `invocationType`: [LambdaInvocationType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.LambdaInvocationType.html) = InvocationType.REQUEST_RESPONSE — Invocation type of the Lambda function.

- `lambdaFunction`: [IFunction](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.IFunction.html) (required) — Lambda function to invoke.

- `outputs`: any — Used to specify and transform output from the state.

  **Default:** $states.result or $states.errorOutput

  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.

- `payload`: [TaskInput](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.TaskInput.html) — The JSON that will be supplied as input to the Lambda function.

  **Default:** The state input (JSONata: '{% $states.input %}', JSONPath: '$')

- `payloadResponseOnly`: boolean = false — Invoke the Lambda in a way that only returns the payload response without additional metadata.

  The `payloadResponseOnly` property cannot be used if `integrationPattern`, `invocationType`,
  `clientContext`, or `qualifier` are specified.
  It always uses the REQUEST_RESPONSE behavior.

- `qualifier`: string — pass a Version or Alias object as lambdaFunction instead

  **Default:** Version or alias inherent to the `lambdaFunction` object.

  You only need to supply this if you want the version of the Lambda Function to depend
  on data in the state machine state. If not, you can pass the appropriate Alias or Version object
  directly as the `lambdaFunction` argument.

- `queryLanguage`: [QueryLanguage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.QueryLanguage.html) = JSONPath — The name of the query language used by the state.

  If the state does not contain a `queryLanguage` field,
  then it will use the query language specified in the top-level `queryLanguage` field.

- `retryOnServiceExceptions`: boolean = true — Whether to retry on Lambda service exceptions.

  This handles `Lambda.ServiceException`, `Lambda.AWSLambdaException`,
  `Lambda.SdkClientException`, and `Lambda.ClientExecutionTimeoutException`
  with an interval of 2 seconds, a back-off rate
  of 2 and 6 maximum attempts.

- `stateName`: string — Optional name for this state.

  **Default:** The construct ID will be used as state name

- `taskTimeout`: [Timeout](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.Timeout.html) = None — Timeout for the task.

  [disable-awslint:duration-prop-type] is needed because all props interface in
  aws-stepfunctions-tasks extend this interface

- `timeout`: [Duration](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — use `taskTimeout`
