AWS Lambda@Edge Nodejs "Environment variables are not supported."
Workaround using custom origin headers
Environment variables are not supported by Lambda@Edge as specified in the limitations documentation.
But if you are using Lambda@Edge either on origin request or origin response, you can use a workaround with CloudFront Origin Custom Headers.
Basically instead of environment variable, you can set custom headers within your CloudFront origin. Those "static" headers will then be passed to your origin request/response Lambda@Edge.
Then you can access them in your Lambda@Edge function code via:
const foo = request.origin.custom.customHeaders["x-env-foo"][0].value;
Or when using S3 as the origin:
const foo = request.origin.s3.customHeaders["x-env-foo"][0].value;
See also https://medium.com/@mnylen/lambda-edge-gotchas-and-tips-93083f8b4152
As mentioned in this documentation for CloudFront Lambda limitations:
Environment variables aren't supported.
What you could do instead is use SSM Parameter Store to manage your function's variables. You can edit Parameter Store variables through the console or programmatically, and you can get the variables using the ssm.getParameter() function