I'm building Lambda function for CloudFront which checks if request has cookies, if not then forwards to login page. I need to customize response header location
based on environment - for each env that will be different.
Initially I tried with environment variables but I got an error during deployment:
InvalidLambdaFunctionAssociation: The function cannot have environment variables
So I switched to use aws-sdk
with SSM ssm.getParameter
but after zipping lambda archive with aws-sdk
and one more depedency it's around 13 MB. The limit for Lambda@Edge functions is 1 MB.
I'm wondering would be the best way to approach that. Generate file with environment variables on each Lambda build and require it in index.js
?