Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . lambda ]

invoke

Description

Invokes a Lambda function. For an example, see Create the Lambda Function and Test It Manually .

Specify just a function name to invoke the latest version of the function. To invoke a published version, use the Qualifier parameter to specify a version or alias .

If you use the RequestResponse (synchronous) invocation option, the function will be invoked only once. If you use the Event (asynchronous) invocation option, the function will be invoked at least once in response to an event and the function must be idempotent to handle this.

For functions with a long timeout, your client may be disconnected during synchronous invocation while it waits for a response. Configure your HTTP client, SDK, firewall, proxy, or operating system to allow for long connections with timeout or keep-alive settings.

This operation requires permission for the lambda:InvokeFunction action.

The TooManyRequestsException noted below will return the following: ConcurrentInvocationLimitExceeded will be returned if you have no functions with reserved concurrency and have exceeded your account concurrent limit or if a function without reserved concurrency exceeds the account's unreserved concurrency limit. ReservedFunctionConcurrentInvocationLimitExceeded will be returned when a function with reserved concurrency exceeds its configured concurrency limit.

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.

Synopsis

  invoke
--function-name <value>
[--invocation-type <value>]
[--log-type <value>]
[--client-context <value>]
[--payload <value>]
[--qualifier <value>]
outfile <value>

Options

--function-name (string)

The name of the lambda function.

Name formats
  • Function name - MyFunction .
  • Function ARN - arn:aws:lambda:us-west-2:123456789012:function:MyFunction .
  • Partial ARN - 123456789012:function:MyFunction .

The length constraint applies only to the full ARN. If you specify only the function name, it is limited to 64 characters in length.

--invocation-type (string)

Choose from the following options.

  • RequestResponse (default) - Invoke the function synchronously. Keep the connection open until the function returns a response or times out.
  • Event - Invoke the function asynchronously. Send events that fail multiple times to the function's dead-letter queue (if configured).
  • DryRun - Validate parameter values and verify that the user or role has permission to invoke the function.

Possible values:

  • Event
  • RequestResponse
  • DryRun

--log-type (string)

You can set this optional parameter to Tail in the request only if you specify the InvocationType parameter with value RequestResponse . In this case, AWS Lambda returns the base64-encoded last 4 KB of log data produced by your Lambda function in the x-amz-log-result header.

Possible values:

  • None
  • Tail

--client-context (string)

Using the ClientContext you can pass client-specific information to the Lambda function you are invoking. You can then process the client information in your Lambda function as you choose through the context variable. For an example of a ClientContext JSON, see PutEvents in the Amazon Mobile Analytics API Reference and User Guide .

The ClientContext JSON must be base64-encoded and has a maximum size of 3583 bytes.

Note

ClientContext information is returned only if you use the synchronous (RequestResponse ) invocation type.

--payload (blob)

JSON that you want to provide to your Lambda function as input.

--qualifier (string)

Specify a version or alias to invoke a published version of the function.

outfile (string) Filename where the content will be saved

See 'aws help' for descriptions of global parameters.

Output

StatusCode -> (integer)

The HTTP status code will be in the 200 range for successful request. For the RequestResponse invocation type this status code will be 200. For the Event invocation type this status code will be 202. For the DryRun invocation type the status code will be 204.

FunctionError -> (string)

Indicates whether an error occurred while executing the Lambda function. If an error occurred this field will have one of two values; Handled or Unhandled . Handled errors are errors that are reported by the function while the Unhandled errors are those detected and reported by AWS Lambda. Unhandled errors include out of memory errors and function timeouts. For information about how to report an Handled error, see Programming Model .

LogResult -> (string)

It is the base64-encoded logs for the Lambda function invocation. This is present only if the invocation type is RequestResponse and the logs were requested.

Payload -> (blob)

It is the JSON representation of the object returned by the Lambda function. This is present only if the invocation type is RequestResponse .

In the event of a function error this field contains a message describing the error. For the Handled errors the Lambda function will report this message. For Unhandled errors AWS Lambda reports the message.

ExecutedVersion -> (string)

The function version that has been executed. This value is returned only if the invocation type is RequestResponse . For more information, see Traffic Shifting Using Aliases .