numo-labs / aws-lambda-helper

:lollipop: Collection of helper methods for lambda
GNU General Public License v3.0
22 stars 2 forks source link

Env vars #51

Open Kumjami opened 8 years ago

Kumjami commented 8 years ago

As far as it's a module. I don't like so much the need to set up some env vars to be able to use it. I think it could be better just to set the required env vars as properties while initializing.

AwsHelper.init({
    ...regularParams,
    websocketServer: <WEBSOCKET_SERVER_URL>,
    s3Bucket: <AWS_S3_SEARCH_RESULT_BUCKET>,
    snsTopic: <SEARCH_RESULT_TOPIC>
})

What do you think? Maybe it's something stupid.

lennym commented 8 years ago

That doesn't really remove the need to set up env vars though, since the code you describe above would look like:

AwsHelper.init({
    ...regularParams,
    websocketServer: process.env.WEBSOCKET_SERVER_URL,
    s3Bucket: process.env.AWS_S3_SEARCH_RESULT_BUCKET,
    snsTopic: process.env.SEARCH_RESULT_TOPIC
});
lennym commented 8 years ago

I think I do agree with the idea though, a re-usable module shouldn't be loading it's own configuration. Rather it should have any required config passed in.

Kumjami commented 8 years ago

@lennym that's exactly what I mean.