This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
/
Copy pathconfig.js
50 lines (44 loc) · 1.5 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
var defaults = {
AWS_PROFILE: 'default',
AWS_REGION: 'us-east-1',
ENVIRONMENT_STAGE: 'development',
PROJECT_PREFIX: 'spacefinder-',
PACKAGE_VERSION: '1.0.0'
};
function getVar(name) {
if (process.env[name]){
console.log('Getting value', name, 'from environmental variable with value', process.env[name], ' overriding ', defaults[name]);
return process.env[name];
}
return defaults[name];
}
var config = {
AWS_PROFILE: getVar('AWS_PROFILE'),
AWS_REGION: getVar('AWS_REGION'),
ENVIRONMENT_STAGE: getVar('ENVIRONMENT_STAGE'),
PROJECT_PREFIX: getVar('PROJECT_PREFIX'),
PACKAGE_VERSION: getVar('PACKAGE_VERSION')
};
// For local development, define these properties before requiring the SDK since it will provide the right credentials
if (!process.env.LAMBDA_TASK_ROOT) {
// Code is not running in a Lambda container, set AWS profile to use
process.env.AWS_PROFILE = config.AWS_PROFILE;
process.env.AWS_REGION = config.AWS_REGION;
}
// Attach this AWS object with credentials setup for other methods.
config.AWS = require('aws-sdk');
config.getName = (suffix) => {
return config.getResourcePrefix() + suffix;
};
config.getResourcePrefix = () => {
return config.PROJECT_PREFIX + config.ENVIRONMENT_STAGE + '-';
};
config.getLambdaZipName = () => {
return 'lambda-' + config.PACKAGE_VERSION + '.zip';
};
config.getLambdaZipPath = () => {
var path = require('path');
return path.join(__dirname, 'dist', 'lambda-' + config.PACKAGE_VERSION + '.zip');
};
module.exports = config;