New API Documentation - Developer Preview Available
We are excited to announce the developer preview of our new API documentation for AWS SDK for JavaScript v3. Please follow instructions on the landing page to leave us your feedback.
Invokes a Lambda function. You can invoke a function synchronously (and wait for the response), or
asynchronously. To invoke a function asynchronously, set InvocationType to Event.
For synchronous invocation,
details about the function response, including errors, are included in the response body and headers. For either
invocation type, you can find more information in the execution log and trace.
When an error occurs, your function may be invoked multiple times. Retry behavior varies by error type,
client, event source, and invocation type. For example, if you invoke a function asynchronously and it returns an
error, Lambda executes the function up to two more times. For more information, see Error handling and automatic retries in
Lambda.
For asynchronous invocation,
Lambda adds events to a queue before sending them to your function. If your function does not have enough capacity
to keep up with the queue, events may be lost. Occasionally, your function may receive the same event multiple
times, even if no error occurs. To retain events that were not processed, configure your function with a dead-letter queue.
The status code in the API response doesn't reflect function errors. Error codes are reserved for errors that
prevent your function from executing, such as permissions errors, quota errors, or issues with your function's code and
configuration. For example, Lambda returns TooManyRequestsException if running the
function would cause you to exceed a concurrency limit at either the account level
(ConcurrentInvocationLimitExceeded) or function level
(ReservedFunctionConcurrentInvocationLimitExceeded).
For functions with a long timeout, your client might disconnect 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.
Lambda couldn't create an elastic network interface in the VPC, specified as part of Lambda function configuration, because the limit for network interfaces has been reached. For more
information, see Lambda
quotas.
Lambda couldn't decrypt the environment variables because the state of the KMS key used is not valid for Decrypt. Check the function's KMS key settings.
Invokes a Lambda function. You can invoke a function synchronously (and wait for the response), or asynchronously. To invoke a function asynchronously, set
InvocationType
toEvent
.For synchronous invocation, details about the function response, including errors, are included in the response body and headers. For either invocation type, you can find more information in the execution log and trace.
When an error occurs, your function may be invoked multiple times. Retry behavior varies by error type, client, event source, and invocation type. For example, if you invoke a function asynchronously and it returns an error, Lambda executes the function up to two more times. For more information, see Error handling and automatic retries in Lambda.
For asynchronous invocation, Lambda adds events to a queue before sending them to your function. If your function does not have enough capacity to keep up with the queue, events may be lost. Occasionally, your function may receive the same event multiple times, even if no error occurs. To retain events that were not processed, configure your function with a dead-letter queue.
The status code in the API response doesn't reflect function errors. Error codes are reserved for errors that prevent your function from executing, such as permissions errors, quota errors, or issues with your function's code and configuration. For example, Lambda returns
TooManyRequestsException
if running the function would cause you to exceed a concurrency limit at either the account level (ConcurrentInvocationLimitExceeded
) or function level (ReservedFunctionConcurrentInvocationLimitExceeded
).For functions with a long timeout, your client might disconnect 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. For details on how to set up permissions for cross-account invocations, see Granting function access to other accounts.
Example
Use a bare-bones client and the command you need to make an API call.
Param
InvokeCommandInput
Returns
InvokeCommandOutput
See
input
shape.response
shape.config
shape.Throws
EC2AccessDeniedException (server fault)
Need additional permissions to configure VPC settings.
Throws
EC2ThrottledException (server fault)
Amazon EC2 throttled Lambda during Lambda function initialization using the execution role provided for the function.
Throws
EC2UnexpectedException (server fault)
Lambda received an unexpected Amazon EC2 client exception while setting up for the Lambda function.
Throws
EFSIOException (client fault)
An error occurred when reading from or writing to a connected file system.
Throws
EFSMountConnectivityException (client fault)
The Lambda function couldn't make a network connection to the configured file system.
Throws
EFSMountFailureException (client fault)
The Lambda function couldn't mount the configured file system due to a permission or configuration issue.
Throws
EFSMountTimeoutException (client fault)
The Lambda function made a network connection to the configured file system, but the mount operation timed out.
Throws
ENILimitReachedException (server fault)
Lambda couldn't create an elastic network interface in the VPC, specified as part of Lambda function configuration, because the limit for network interfaces has been reached. For more information, see Lambda quotas.
Throws
InvalidParameterValueException (client fault)
One of the parameters in the request is not valid.
Throws
InvalidRequestContentException (client fault)
The request body could not be parsed as JSON.
Throws
InvalidRuntimeException (server fault)
The runtime or runtime version specified is not supported.
Throws
InvalidSecurityGroupIDException (server fault)
The security group ID provided in the Lambda function VPC configuration is not valid.
Throws
InvalidSubnetIDException (server fault)
The subnet ID provided in the Lambda function VPC configuration is not valid.
Throws
InvalidZipFileException (server fault)
Lambda could not unzip the deployment package.
Throws
KMSAccessDeniedException (server fault)
Lambda couldn't decrypt the environment variables because KMS access was denied. Check the Lambda function's KMS permissions.
Throws
KMSDisabledException (server fault)
Lambda couldn't decrypt the environment variables because the KMS key used is disabled. Check the Lambda function's KMS key settings.
Throws
KMSInvalidStateException (server fault)
Lambda couldn't decrypt the environment variables because the state of the KMS key used is not valid for Decrypt. Check the function's KMS key settings.
Throws
KMSNotFoundException (server fault)
Lambda couldn't decrypt the environment variables because the KMS key was not found. Check the function's KMS key settings.
Throws
RequestTooLargeException (client fault)
The request payload exceeded the
Invoke
request body JSON input quota. For more information, see Lambda quotas.Throws
ResourceConflictException (client fault)
The resource already exists, or another operation is in progress.
Throws
ResourceNotFoundException (client fault)
The resource specified in the request does not exist.
Throws
ResourceNotReadyException (server fault)
The function is inactive and its VPC connection is no longer available. Wait for the VPC connection to reestablish and try again.
Throws
ServiceException (server fault)
The Lambda service encountered an internal error.
Throws
SnapStartException (client fault)
The
afterRestore()
runtime hook encountered an error. For more information, check the Amazon CloudWatch logs.Throws
SnapStartNotReadyException (client fault)
Lambda is initializing your function. You can invoke the function when the function state becomes
Active
.Throws
SnapStartTimeoutException (client fault)
Lambda couldn't restore the snapshot within the timeout limit.
Throws
SubnetIPAddressLimitReachedException (server fault)
Lambda couldn't set up VPC access for the Lambda function because one or more configured subnets has no available IP addresses.
Throws
TooManyRequestsException (client fault)
The request throughput limit was exceeded. For more information, see Lambda quotas.
Throws
UnsupportedMediaTypeException (client fault)
The content type of the
Invoke
request body is not JSON.Throws
LambdaServiceException
Base exception class for all service exceptions from Lambda service.