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 Antwort
0
Akzeptierte Antwort

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
EXPERTE
Matt-B
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen