Cannot find module 'aws-cloudfront-sign'

0

I want to create cloudfront presigned URL in my lambda function through this code:

import { createRequire } from 'module';
const require = createRequire(import.meta.url);
var AWS = require('aws-cloudfront-sign');

export const handler = async(event) => {

    
    var signingParams = {
  keypairId: "************************************",
  privateKeyString: "****************************************",

  privateKeyPath: '/path/to/private/key',
  expireTime: 1426625464599
}

var signedUrl = AWS.getSignedUrl(
  'http://example.cloudfront.net/path/to/s3/object', 
  signingParams
);

console.log(signedUrl);
};

I don't know what is happening. Another question, I have 2 keys rsa xxxxxxx.pem & pk xxxxxxxxx.pem. I'm placing the rsa.pem in keypairid and pk.pem in private key string by removing -----END RSA PRIVATE KEY----- & -----BEGIN RSA PRIVATE KEY----- from the strings.

已提问 1 年前300 查看次数
1 回答
0
已接受的回答

For the missing dependency, you need to deploy your Lambda function as a package with all of the dependencies included. If your function depends on libraries other than the AWS SDK for JavaScript, use npm to include them in your deployment package. See https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies

Also please take a look at some example code for your use case here: https://www.npmjs.com/package/aws-cloudfront-sign?activeTab=explore

profile pictureAWS
专家
Matt-B
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则