-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathupload-environment.js
More file actions
20 lines (16 loc) · 924 Bytes
/
upload-environment.js
File metadata and controls
20 lines (16 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Promise from 'bluebird'
import merge from 'lodash.merge'
import { getFunction, updateFunction, doesAliasExist } from './aws/lambda'
import { lambdaConfig, funcs } from './load'
const pattern = '*'
export default async function (env, vars) {
const configs = await Promise.map(funcs(pattern), async (name) => { return { name, config: await lambdaConfig(name, env) } })
return Promise.map(configs, async ({name, config}) => {
const aliasExists = await doesAliasExist({ FunctionName: config.FunctionName, Alias: env })
const oldFunc = await getFunction({ FunctionName: config.FunctionName, Qualifier: (aliasExists ? env : undefined) })
oldFunc.Identifier.Alias = env
const wantedFunc = { Code: {}, Config: { Environment: {} } }
wantedFunc.Config.Environment = merge({}, oldFunc.Config.Environment, { Variables: vars })
return updateFunction(oldFunc, wantedFunc)
}, { concurrency: 1 })
}