Skip to content

Commit

Permalink
Merge pull request #1032 from chardos/resolve-joins
Browse files Browse the repository at this point in the history
feat: Resolve Fn::Join in environment variables
  • Loading branch information
dherault committed Jun 23, 2020
2 parents f893da3 + f089c13 commit 8d10387
Show file tree
Hide file tree
Showing 2 changed files with 26 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
24 changes: 24 additions & 0 deletions src/utils/resolveJoins.js
@@ -0,0 +1,24 @@
// Used to resolve Fn::Join in environment variables
export default function resolveJoins(environment) {
if (!environment) {
return undefined
}

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 8d10387

Please sign in to comment.