Lambda@edge environment variables in a Serverless project


Working on a serverless project that includes a lambda@edge trigger.

Lambda@edge functions do not allow setting any environment variables. In my project, I need lambda functions and labda@edge functions to co-exist. However I have some global environment variables that are set in the environment section of my serverless.yml file. This causes an error on deploy:

An error occurred: CloudFrontDistribution - The function cannot have environment variables. Function: arn:aws:lambda:us-east-1:973909360769:function:designstripe-dev-cfLambda:3 (Service: AmazonCloudFront; Status Code: 400; Error Code: InvalidLambdaFunctionAssociation; Request ID: 9968b538-7d9e-49d2-9a8c-91f99291db54).

My functions are packaged individually, and because of that, every function has the globally defined environment variables set. I could, in order to get around the issue, set variables per function, but I have many of them and it would just bloat the config file.

Is there any way that one can unset environment variable definitions for a specific function?

Thank you!

I would like this too. You might say, just use two different serverless.ymls, but I feel like it would be a simple solution for serverless to have a feature like:


edge: true

or something, that automatically limits memory to 128mb, limits timeout to 5, and removes environment variables. Or, at least a way to manually remove environment variables from a function, so that global ones can still exist. There isn’t currently a way to do this, is there?