我正在使用 javascript 创建 lambda 函数,以使用 AWS Cognito 和身份池对用户进行身份验证。但我需要在我的 lambda 函数代码中包含以下 JS 库引用
aws-cognito-sdk.js
amazon-cognito-identity.min.js
aws-sdk.min.js"
moment.js
sjcl.js
jsbn.js
jsbn2.js
下面给出的是我在 lambda 函数的处理程序中使用的代码部分。如何在我的 lambda 函数代码中包含对上述 javascript 的引用?
exports.handler = function(event, context, callback)
{
// Cognito Identity Pool Id
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:xxxxxxxxxx',
});
// Cognito User Pool Id
AWSCognito.config.region = 'us-east-1';
AWSCognito.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:xxxxxxxx'
});
//...rest of the logic..
}
最佳答案
好吧,您可以将这些库放入 Node 包(如果还没有),然后使用“require”来包含它们。缺点是从那时起您必须将它们作为压缩文件夹上传,而不是在其网络编辑器中工作。
关于javascript - 在 AWS Lambda Javascript 文件中包含 Javascript 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38079771/