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 Resposta
0
Resposta aceita

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
ESPECIALISTA
Matt-B
respondido há um ano

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas