@1mill/lambda 中文文档教程
lambda
@aws-sdk/client-lambda
库的简单包装器,用于使用 Cloudevents 调用 AWS Lambda 函数。
Usage
Node
<script src="https://unpkg.com/@1mill/lambda@0.4/dist/index.umd.js"></script>
或者
npm install @1mill/lambda
const { Lambda } = require('@1mill/lambda') // CommonJS
import { Lambda } from '@1mill/lambda' // EMS
const lambda = new Lambda({
accessKeyId: 'required' || process.env.MILL_LAMBDA_AWS_ACCESS_KEY_ID,
endpoint: 'optional' || process.env.MILL_LAMBDA_AWS_ENDPOINT,
region: 'required' || process.env.MILL_LAMBDA_AWS_REGION,
secretAccessKey: 'required' || process.env.MILL_LAMBDA_AWS_SECRET_ACCESS_KEY,
})
Required | Default | Notes | |
---|---|---|---|
accessKeyId | yes | process.env.MILLLAMBDAAWSACCESSKEY_ID | |
endpoint | process.env.MILLLAMBDAAWS_ENDPOINT | Good for local development environment when using Localstack (or other AWS simulators) | |
region | yes | process.env.MILLLAMBDAAWS_REGION | |
secretAccessKey | yes | process.env.MILLLAMBDAAWSSECRETACCESS_KEY |
const lambda = new Lambda({...})
await lambda.invoke({
cloudevent,
functionName: 'required-my-lambda-arn',
invocationType: 'optional' || 'Event',
})
Required | Default | Notes | |
---|---|---|---|
cloudevent | yes | @1mill/cloudevents | |
functionname | yes | ||
invocationType | 'Event' | Options are 'Event' or 'RequestResponse' |
lambda
Simple wrapper around the @aws-sdk/client-lambda
library to invoke AWS Lambda functions with Cloudevents.
Usage
Node
<script src="https://unpkg.com/@1mill/lambda@0.4/dist/index.umd.js"></script>
or
npm install @1mill/lambda
const { Lambda } = require('@1mill/lambda') // CommonJS
import { Lambda } from '@1mill/lambda' // EMS
const lambda = new Lambda({
accessKeyId: 'required' || process.env.MILL_LAMBDA_AWS_ACCESS_KEY_ID,
endpoint: 'optional' || process.env.MILL_LAMBDA_AWS_ENDPOINT,
region: 'required' || process.env.MILL_LAMBDA_AWS_REGION,
secretAccessKey: 'required' || process.env.MILL_LAMBDA_AWS_SECRET_ACCESS_KEY,
})
Required | Default | Notes | |
---|---|---|---|
accessKeyId | yes | process.env.MILLLAMBDAAWSACCESSKEY_ID | |
endpoint | process.env.MILLLAMBDAAWS_ENDPOINT | Good for local development environment when using Localstack (or other AWS simulators) | |
region | yes | process.env.MILLLAMBDAAWS_REGION | |
secretAccessKey | yes | process.env.MILLLAMBDAAWSSECRETACCESS_KEY |
const lambda = new Lambda({...})
await lambda.invoke({
cloudevent,
functionName: 'required-my-lambda-arn',
invocationType: 'optional' || 'Event',
})
Required | Default | Notes | |
---|---|---|---|
cloudevent | yes | @1mill/cloudevents | |
functionname | yes | ||
invocationType | 'Event' | Options are 'Event' or 'RequestResponse' |