@aws-sdk/client-lambda
TypeScript icon, indicating that this package has built-in type declarations

3.563.0 • Public • Published

@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 the this package, simply type add or install @aws-sdk/client-lambda using 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, you:

  • Initiate client with configuration (e.g. credentials, region).
  • Initiate command with input parameters.
  • Call send operation on client with command object as input.
  • If you are using a custom http handler, you may call destroy() to close open connections.
// a client can be shared by different commands.
const client = new LambdaClient({ region: "REGION" });

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

Async/await

We recommend using 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.
}

Async-await is clean, concise, intuitive, easy to debug and has better error handling as compared to using Promise chains or callbacks.

Promises

You can also use Promise chaining to execute send operation.

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

Promises can also be called using .catch() and .finally() as follows:

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

Callbacks

We do not recommend using callbacks because of callback hell, but they are supported by the send operation.

// callbacks.
client.send(command, (err, data) => {
  // process err and data.
});

v2 compatible style

The client can also send requests using v2 compatible style. However, it results in a bigger bundle size and may be dropped in next major version. More details in the blog post on modular packages in AWS SDK for JavaScript

import * as AWS from "@aws-sdk/client-lambda";
const client = new AWS.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.
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;
   * }
   */
}

Getting Help

Please use these community resources for getting help. We use the 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

CreateAlias

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

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

GetCodeSigningConfig

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

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

ListCodeSigningConfigs

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

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

PutProvisionedConcurrencyConfig

Command API Reference / Input / Output

PutRuntimeManagementConfig

Command API Reference / Input / Output

RemoveLayerVersionPermission

Command API Reference / Input / Output

RemovePermission

Command API Reference / Input / Output

TagResource

Command API Reference / Input / Output

UntagResource

Command API Reference / Input / Output

UpdateAlias

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

Readme

Keywords

none

Package Sidebar

Install

npm i @aws-sdk/client-lambda

Weekly Downloads

2,045,068

Version

3.563.0

License

Apache-2.0

Unpacked Size

1.59 MB

Total Files

326

Last publish

Collaborators

  • mattsb42-aws
  • kuhe
  • amzn-oss
  • aws-sdk-bot
  • trivikr-aws