aws-lambda
100000 请求 30s/per
AWS Lambda 免费套餐包括每月 100 万次免费请求和 400000 GB 秒的计算时间,可用于由 x86、Graviton2 处理器或两者整合提供支持的函数。 此外,免费套餐包括每月 100GiB 的 HTTP 响应流,不包括每个请求的前 6MB(免费)
安装
- 安装 aws
- 配置 aws
aws configure - 验证是否登录成功
aws lambda list-functions
客户端
nodejs
pnpm add @aws-sdk/client-lambda
import { InvokeCommand, InvokeCommandInput, LambdaClient, ListLayersCommand } from "@aws-sdk/client-lambda";
const config = {
region: "ap-east-1"
}
const client = new LambdaClient(config);
export interface IGetDnsBody {
domains: string[],
dnsServers: string[]
}
//数据在 response.payload
async function getDns(body: IGetDnsBody) {
const input = { // InvocationRequest
FunctionName: "getDns", // required
Payload: new TextEncoder().encode(JSON.stringify(body))
};
const command = new InvokeCommand(input);
const response = await client.send(command);
//response body
return response.Payload;
}