Skip to content

Commit

Permalink
feat: Resolve Fn::Join in environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
chardos committed Jun 23, 2020
1 parent c4b6b9c commit fe07475
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lambda/LambdaFunction.js
Expand Up @@ -6,6 +6,7 @@ import jszip from 'jszip'
import HandlerRunner from './handler-runner/index.js'
import LambdaContext from './LambdaContext.js'
import serverlessLog from '../serverlessLog.js'
import resolveJoins from '../utils/resolveJoins.js'
import {
DEFAULT_LAMBDA_MEMORY_SIZE,
DEFAULT_LAMBDA_RUNTIME,
Expand Down Expand Up @@ -77,7 +78,7 @@ export default class LambdaFunction {
this._verifySupportedRuntime()

const env = this._getEnv(
provider.environment,
resolveJoins(provider.environment),
functionDefinition.environment,
handler,
)
Expand Down
20 changes: 20 additions & 0 deletions src/utils/resolveJoins.js
@@ -0,0 +1,20 @@
// Used to resolve Fn::Join in environment variables
export default function resolveJoins(environment) {
const newEnv = {}

Object.keys(environment).forEach((key) => {
const value = environment[key]
const joinArray = value['Fn::Join']
const isJoin = Boolean(joinArray)

if (isJoin) {
const separator = joinArray[0]
const joined = joinArray[1].join(separator)
newEnv[key] = joined
} else {
newEnv[key] = value
}
})

return newEnv
}

0 comments on commit fe07475

Please sign in to comment.