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 15, 2020
1 parent a7bec25 commit dc71c53
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lambda/LambdaFunction.js
Original file line number Diff line number Diff line change
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
19 changes: 19 additions & 0 deletions src/utils/resolveJoins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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);
return newEnv[key] = joined;
}
newEnv[key] = value;
})

return newEnv;
}

0 comments on commit dc71c53

Please sign in to comment.