silvermine / serverless-plugin-cloudfront-lambda-edge

Adds Lambda@Edge support to Serverless
MIT License
296 stars 41 forks source link

POC: Add environment variable injection to plugin #77

Open ryanolee opened 2 years ago

ryanolee commented 2 years ago

What?

This a proof of concept for the proposal given in #76

Why?

To show the viability of implementing such a change.

How?

Currently this PR parses the new configuration option and adds environment variables to the handler associated with the file. There is no duplication detection / function specific isolation but this should be possible by copying the handlers js file and later on updating the handler config to use the file with the isolated ENV over the shared handler file.

What needs doing still:

In the event this is seen to be a reasonable feature to implement proper environment separation / collection will need to be set up. Beyond that documentation will need to be written preferably with a set of unit tests. If possible support should also be added for python runtimes using the os.environ over the process.env variable.

Beyond that a few tests need writing for the implementation.

In theory we could use something like https://webpack.js.org/plugins/environment-plugin/ over injecting the env vars ourselves :thinking:

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-3.1%) to 13.187% when pulling 7b046e804d8645e6740138a0f1e3c8362ead1a1d on ryanolee:feature/InjectEnv into 157f0af8cba2463c61f250dc74c34ff0c36059e9 on silvermine:master.

coveralls commented 2 years ago

Coverage Status

Coverage decreased (-3.1%) to 13.187% when pulling 7b046e804d8645e6740138a0f1e3c8362ead1a1d on ryanolee:feature/InjectEnv into 157f0af8cba2463c61f250dc74c34ff0c36059e9 on silvermine:master.