RSA Private Key set as environment variable on AWS Lambda configuration returns error

Viewed 42

I have an RSA private key set as an environment variable in AWS Lambda (set through the console).

After setting the cfSigner variable:

  const cfSigner = new aws.CloudFront.Signer(
    process.env.CLOUDFRONT_PUB_KEY_ID,
    process.env.CLOUDFRONT_PRIVATE_KEY
  );

Running the getSignedUrl method on cfSigner returns the following error:

PEM routines:get_name:no start line

But when logged in to the console, the key exists.

So I tried using a .env file in my serverless folder instead, and, curiously enough, it solved the issue. But I always try to avoid storing secrets in the .env file and I'd rather store them in the AWS lambda configuration directly in the "Environment variables" section.

How do I solve this problem?

0 Answers
Related