Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Resolve Fn::Join in environment variables #1020

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
20 changes: 20 additions & 0 deletions src/utils/resolveJoins.js
Original file line number Diff line number Diff line change
@@ -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
}