# LambdaInvokeProps

Properties for invoking a Lambda function with LambdaInvoke.

Extends: LambdaInvokeProps
Extends: TaskStateBaseProps
Used as props by: LambdaInvoke

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

## Example

```ts
declare const fn: lambda.Function;
new tasks.LambdaInvoke(this, 'Invoke with empty object as payload', {
  lambdaFunction: fn,
  payload: sfn.TaskInput.fromObject({}),
});

// use the output of fn as input
new tasks.LambdaInvoke(this, 'Invoke with payload field in the state input', {
  lambdaFunction: fn,
  payload: sfn.TaskInput.fromJsonPathAt('$.Payload'),
});
```

## 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](/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](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — use `heartbeatTimeout`

- `heartbeatTimeout`: [Timeout](/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

- `inputPath`: string = $ — JSONPath expression to select part of the state to be the input to this state.

  May also be the special value JsonPath.DISCARD, which will cause the effective
  input to be the empty object {}.

- `integrationPattern`: [IntegrationPattern](/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](/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.LambdaInvocationType.html) = InvocationType.REQUEST_RESPONSE — Invocation type of the Lambda function.

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

- `outputPath`: string = $ — JSONPath expression to select part of the state to be the output to this state.

  May also be the special value JsonPath.DISCARD, which will cause the effective
  output to be the empty object {}.

- `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](/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](/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.

- `resultPath`: string = $ — JSONPath expression to indicate where to inject the state's output.

  May also be the special value JsonPath.DISCARD, which will cause the state's
  input to become its output.

- `resultSelector`: { [key: string]: any } = None — The JSON that will replace the state's raw result and become the effective result before ResultPath is applied.

  You can use ResultSelector to create a payload with values that are static
  or selected from the state's raw result.

- `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](/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](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = None — use `taskTimeout`
