Hey everyone,
I’m curious how others handle AWS Lambda usage across multiple environments in Retool.
We’re using a single AWS account where both staging and production Lambdas are deployed. For each function, that means we end up with two separate Lambdas — e.g. one for staging and one for production.
When configuring a Lambda resource in Retool, you can only pick one function name from the dropdown (which lists all functions). Unlike API resources — where you can define a different base URL for each environment — there’s no built-in way to dynamically select the function name based on retoolContext.environment.
Because our Lambda names are auto-generated by CloudFormation (e.g. MyAppStackstaging-createUser-abc123), we can’t rely on a predictable or shared naming convention across environments.
Using custom function names could simplify that, but AWS generally recommends letting the stack generate names automatically to avoid conflicts and deployment issues — so we’re trying to follow that best practice.
To make this work in Retool, we currently have a mapping defined in Advanced Settings → Preloaded JavaScript:
const lambdas = {
staging: {
createUser: 'MyAppStackstaging-createUser-abc123',
updateAccount: 'MyAppStackstaging-updateAccount-def456'
},
production: {
createUser: 'MyAppStackprod-createUser-xyz789',
updateAccount: 'MyAppStackprod-updateAccount-uvw987'
}
};
function lambdaForEnvironment(environment, name) {
return lambdas[environment][name];
}
Then in our queries we use:
lambdaForEnvironment(retoolContext.environment, 'createUser')
This works fine — but it feels like a workaround.
I also tried using Lambda aliases, which would have let us do something like functionName-{{ retoolContext.environment }}, but Retool’s Lambda integration doesn’t allow dynamic names — it only accepts static function names.
We could also store function names as environment variables, but so far our JS mapping feels like the most flexible and straightforward solution, even if it’s not ideal.
Curious how others handle this:
-
Do you use separate AWS accounts per environment?
-
Or have you found a cleaner way to dynamically resolve Lambda names in Retool?
Would love to hear what patterns others are using.