Skip to content

Latest commit

 

History

History

README.md

@aws-sdk/client-lambda

Description

AWS SDK for JavaScript Lambda Client for Node.js, Browser and React Native.

Lambda

Overview

Lambda is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code on a high-availability compute infrastructure and performs all of the administration of the compute resources, including server and operating system maintenance, capacity provisioning and automatic scaling, code monitoring and logging. With Lambda, you can run code for virtually any type of application or backend service. For more information about the Lambda service, see What is Lambda in the Lambda Developer Guide.

The Lambda API Reference provides information about each of the API methods, including details about the parameters in each API request and response.

You can use Software Development Kits (SDKs), Integrated Development Environment (IDE) Toolkits, and command line tools to access the API. For installation instructions, see Tools for Amazon Web Services.

For a list of Region-specific endpoints that Lambda supports, see Lambda endpoints and quotas in the Amazon Web Services General Reference..

When making the API calls, you will need to authenticate your request by providing a signature. Lambda supports signature version 4. For more information, see Signature Version 4 signing process in the Amazon Web Services General Reference..

CA certificates

Because Amazon Web Services SDKs use the CA certificates from your computer, changes to the certificates on the Amazon Web Services servers can cause connection failures when you attempt to use an SDK. You can prevent these failures by keeping your computer's CA certificates and operating system up-to-date. If you encounter this issue in a corporate environment and do not manage your own computer, you might need to ask an administrator to assist with the update process. The following list shows minimum operating system and Java versions:

  • Microsoft Windows versions that have updates from January 2005 or later installed contain at least one of the required CAs in their trust list.

  • Mac OS X 10.4 with Java for Mac OS X 10.4 Release 5 (February 2007), Mac OS X 10.5 (October 2007), and later versions contain at least one of the required CAs in their trust list.

  • Red Hat Enterprise Linux 5 (March 2007), 6, and 7 and CentOS 5, 6, and 7 all contain at least one of the required CAs in their default trusted CA list.

  • Java 1.4.2_12 (May 2006), 5 Update 2 (March 2005), and all later versions, including Java 6 (December 2006), 7, and 8, contain at least one of the required CAs in their default trusted CA list.

When accessing the Lambda management console or Lambda API endpoints, whether through browsers or programmatically, you will need to ensure your client machines support any of the following CAs:

  • Amazon Root CA 1

  • Starfield Services Root Certificate Authority - G2

  • Starfield Class 2 Certification Authority

Root certificates from the first two authorities are available from Amazon trust services, but keeping your computer up-to-date is the more straightforward solution. To learn more about ACM-provided certificates, see Amazon Web Services Certificate Manager FAQs.

Installing

To install this package, use the CLI of your favorite package manager:

  • npm install @aws-sdk/client-lambda
  • yarn add @aws-sdk/client-lambda
  • pnpm add @aws-sdk/client-lambda

Getting Started

Import

The AWS SDK is modulized by clients and commands. To send a request, you only need to import the LambdaClient and the commands you need, for example ListLayersCommand:

// ES5 example
const { LambdaClient, ListLayersCommand } = require("@aws-sdk/client-lambda");
// ES6+ example
import { LambdaClient, ListLayersCommand } from "@aws-sdk/client-lambda";

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
const client = new LambdaClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new ListLayersCommand(params);

Async/await

We recommend using the await operator to wait for the promise returned by send operation as follows:

// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Promises

You can also use Promise chaining.

client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

Lambda extends LambdaClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (LambdaClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

import { Lambda } from "@aws-sdk/client-lambda";

const client = new Lambda({ region: "REGION" });

// async/await.
try {
  const data = await client.listLayers(params);
  // process data.
} catch (error) {
  // error handling.
}

// Promises.
client
  .listLayers(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks (not recommended).
client.listLayers(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-lambda package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

AddLayerVersionPermission

Command API Reference / Input / Output

AddPermission

Command API Reference / Input / Output

CheckpointDurableExecution

Command API Reference / Input / Output

CreateAlias

Command API Reference / Input / Output

CreateCapacityProvider

Command API Reference / Input / Output

CreateCodeSigningConfig

Command API Reference / Input / Output

CreateEventSourceMapping

Command API Reference / Input / Output

CreateFunction

Command API Reference / Input / Output

CreateFunctionUrlConfig

Command API Reference / Input / Output

DeleteAlias

Command API Reference / Input / Output

DeleteCapacityProvider

Command API Reference / Input / Output

DeleteCodeSigningConfig

Command API Reference / Input / Output

DeleteEventSourceMapping

Command API Reference / Input / Output

DeleteFunction

Command API Reference / Input / Output

DeleteFunctionCodeSigningConfig

Command API Reference / Input / Output

DeleteFunctionConcurrency

Command API Reference / Input / Output

DeleteFunctionEventInvokeConfig

Command API Reference / Input / Output

DeleteFunctionUrlConfig

Command API Reference / Input / Output

DeleteLayerVersion

Command API Reference / Input / Output

DeleteProvisionedConcurrencyConfig

Command API Reference / Input / Output

GetAccountSettings

Command API Reference / Input / Output

GetAlias

Command API Reference / Input / Output

GetCapacityProvider

Command API Reference / Input / Output

GetCodeSigningConfig

Command API Reference / Input / Output

GetDurableExecution

Command API Reference / Input / Output

GetDurableExecutionHistory

Command API Reference / Input / Output

GetDurableExecutionState

Command API Reference / Input / Output

GetEventSourceMapping

Command API Reference / Input / Output

GetFunction

Command API Reference / Input / Output

GetFunctionCodeSigningConfig

Command API Reference / Input / Output

GetFunctionConcurrency

Command API Reference / Input / Output

GetFunctionConfiguration

Command API Reference / Input / Output

GetFunctionEventInvokeConfig

Command API Reference / Input / Output

GetFunctionRecursionConfig

Command API Reference / Input / Output

GetFunctionScalingConfig

Command API Reference / Input / Output

GetFunctionUrlConfig

Command API Reference / Input / Output

GetLayerVersion

Command API Reference / Input / Output

GetLayerVersionByArn

Command API Reference / Input / Output

GetLayerVersionPolicy

Command API Reference / Input / Output

GetPolicy

Command API Reference / Input / Output

GetProvisionedConcurrencyConfig

Command API Reference / Input / Output

GetRuntimeManagementConfig

Command API Reference / Input / Output

Invoke

Command API Reference / Input / Output

InvokeAsync

Command API Reference / Input / Output

InvokeWithResponseStream

Command API Reference / Input / Output

ListAliases

Command API Reference / Input / Output

ListCapacityProviders

Command API Reference / Input / Output

ListCodeSigningConfigs

Command API Reference / Input / Output

ListDurableExecutionsByFunction

Command API Reference / Input / Output

ListEventSourceMappings

Command API Reference / Input / Output

ListFunctionEventInvokeConfigs

Command API Reference / Input / Output

ListFunctions

Command API Reference / Input / Output

ListFunctionsByCodeSigningConfig

Command API Reference / Input / Output

ListFunctionUrlConfigs

Command API Reference / Input / Output

ListFunctionVersionsByCapacityProvider

Command API Reference / Input / Output

ListLayers

Command API Reference / Input / Output

ListLayerVersions

Command API Reference / Input / Output

ListProvisionedConcurrencyConfigs

Command API Reference / Input / Output

ListTags

Command API Reference / Input / Output

ListVersionsByFunction

Command API Reference / Input / Output

PublishLayerVersion

Command API Reference / Input / Output

PublishVersion

Command API Reference / Input / Output

PutFunctionCodeSigningConfig

Command API Reference / Input / Output

PutFunctionConcurrency

Command API Reference / Input / Output

PutFunctionEventInvokeConfig

Command API Reference / Input / Output

PutFunctionRecursionConfig

Command API Reference / Input / Output

PutFunctionScalingConfig

Command API Reference / Input / Output

PutProvisionedConcurrencyConfig

Command API Reference / Input / Output

PutRuntimeManagementConfig

Command API Reference / Input / Output

RemoveLayerVersionPermission

Command API Reference / Input / Output

RemovePermission

Command API Reference / Input / Output

SendDurableExecutionCallbackFailure

Command API Reference / Input / Output

SendDurableExecutionCallbackHeartbeat

Command API Reference / Input / Output

SendDurableExecutionCallbackSuccess

Command API Reference / Input / Output

StopDurableExecution

Command API Reference / Input / Output

TagResource

Command API Reference / Input / Output

UntagResource

Command API Reference / Input / Output

UpdateAlias

Command API Reference / Input / Output

UpdateCapacityProvider

Command API Reference / Input / Output

UpdateCodeSigningConfig

Command API Reference / Input / Output

UpdateEventSourceMapping

Command API Reference / Input / Output

UpdateFunctionCode

Command API Reference / Input / Output

UpdateFunctionConfiguration

Command API Reference / Input / Output

UpdateFunctionEventInvokeConfig

Command API Reference / Input / Output

UpdateFunctionUrlConfig

Command API Reference / Input / Output