@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:
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, 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
:
const { LambdaClient, ListLayersCommand } = require("@aws-sdk/client-lambda");
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.
const client = new LambdaClient({ region: "REGION" });
const params = {
};
const command = new ListLayersCommand(params);
Async/await
We recommend using await
operator to wait for the promise returned by send operation as follows:
try {
const data = await client.send(command);
} catch (error) {
} 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) => {
},
(error) => {
}
);
Promises can also be called using .catch()
and .finally()
as follows:
client
.send(command)
.then((data) => {
})
.catch((error) => {
})
.finally(() => {
});
Callbacks
We do not recommend using callbacks because of callback hell,
but they are supported by the send operation.
client.send(command, (err, 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" });
try {
const data = await client.listLayers(params);
} catch (error) {
}
client
.listLayers(params)
.then((data) => {
})
.catch((error) => {
});
client.listLayers(params, (err, 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);
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
}
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
GetFunctionRecursionConfig
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
PutFunctionRecursionConfig
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