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.

preguntada hace un año300 visualizaciones
1 Respuesta
0
Respuesta aceptada

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
EXPERTO
Matt-B
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas