Skip to content
v2.278.0

LambdaInvokeJsonataProps Struct ​

Properties for invoking a Lambda function with LambdaInvoke using Jsonata.

Example ​

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
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
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());
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 %}" }
    })
});
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 ​

assignoptional{ [key: string]: any }assignoptionaltyping.Mapping[str, Any]assignoptionalMap<String, Object>AssignoptionalIDictionary<string, object>Assignoptional*map[string]interface{} #
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.

clientContextoptionalstringclient_contextoptionalstrclientContextoptionalStringClientContextoptionalstringClientContextoptional*string #
Up to 3583 bytes of base64-encoded data about the invoking client to pass to the function.

Default: No context

commentoptionalstringcommentoptionalstrcommentoptionalStringCommentoptionalstringCommentoptional*string #
A comment describing this state.

Default: No comment

credentialsoptionalCredentialscredentialsoptionalCredentialscredentialsoptionalCredentialsCredentialsoptionalCredentialsCredentialsoptionalCredentials #
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.

heartbeatoptionalDurationheartbeatoptionalDurationheartbeatoptionalDurationHeartbeatoptionalDurationHeartbeatoptionalDuration = None deprecated #
use `heartbeatTimeout`
heartbeatTimeoutoptionalTimeoutheartbeat_timeoutoptionalTimeoutheartbeatTimeoutoptionalTimeoutHeartbeatTimeoutoptionalTimeoutHeartbeatTimeoutoptionalTimeout = None #
Timeout for the heartbeat.

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

integrationPatternoptionalIntegrationPatternintegration_patternoptionalIntegrationPatternintegrationPatternoptionalIntegrationPatternIntegrationPatternoptionalIntegrationPatternIntegrationPatternoptionalIntegrationPattern #
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.

invocationTypeoptionalLambdaInvocationTypeinvocation_typeoptionalLambdaInvocationTypeinvocationTypeoptionalLambdaInvocationTypeInvocationTypeoptionalLambdaInvocationTypeInvocationTypeoptionalLambdaInvocationType = InvocationType.REQUEST_RESPONSE #
Invocation type of the Lambda function.
lambdaFunctionIFunctionlambda_functionIFunctionlambdaFunctionIFunctionLambdaFunctionIFunctionLambdaFunctionIFunction required #
Lambda function to invoke.
outputsoptionalanyoutputsoptionalAnyoutputsoptionalObjectOutputsoptionalobjectOutputsoptionalinterface{} #
Used to specify and transform output from the state.

Default: $states.result or $states.errorOutput

notes

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.

payloadoptionalTaskInputpayloadoptionalTaskInputpayloadoptionalTaskInputPayloadoptionalTaskInputPayloadoptionalTaskInput #
The JSON that will be supplied as input to the Lambda function.

Default: The state input (JSONata: '{% states.input')

payloadResponseOnlyoptionalbooleanpayload_response_onlyoptionalboolpayloadResponseOnlyoptionalBooleanPayloadResponseOnlyoptionalboolPayloadResponseOnlyoptional*bool = 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.

qualifieroptionalstringqualifieroptionalstrqualifieroptionalStringQualifieroptionalstringQualifieroptional*string deprecated #
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.

queryLanguageoptionalQueryLanguagequery_languageoptionalQueryLanguagequeryLanguageoptionalQueryLanguageQueryLanguageoptionalQueryLanguageQueryLanguageoptionalQueryLanguage = 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.

retryOnServiceExceptionsoptionalbooleanretry_on_service_exceptionsoptionalboolretryOnServiceExceptionsoptionalBooleanRetryOnServiceExceptionsoptionalboolRetryOnServiceExceptionsoptional*bool = 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.

stateNameoptionalstringstate_nameoptionalstrstateNameoptionalStringStateNameoptionalstringStateNameoptional*string #
Optional name for this state.

Default: The construct ID will be used as state name

taskTimeoutoptionalTimeouttask_timeoutoptionalTimeouttaskTimeoutoptionalTimeoutTaskTimeoutoptionalTimeoutTaskTimeoutoptionalTimeout = None #
Timeout for the task.

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

timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration = None deprecated #
use `taskTimeout`