The short version is that Remotion-Lambda isstilllooking for either actual environment variables (AWS_ACCESS_KEY_ID/REMOTION_AWS_ACCESS_KEY_ID) or credentials passed in a way it recognizes, and not finding them. Even though you can see your keys by callingDeno.env.get(...), that doesnotnecessarily mean that Remotion’s internal credential check sees them—especially in a (Supabase Edge Functions) environment, which handles environment variables differently than Node.
Below are the main reasons (and possible fixes):
- Remotion’s built-in credential check expects Nodeprocess.env(not )
Remotion’s code that emits:
────────────────────────────────────────────────────────────────────
Copy codeError: You have tried to call a function, but have not set the environment variable AWS_ACCESS_KEY_ID or REMOTION_AWS_ACCESS_KEY_ID.
comes fromcheck-credentials.mjs. In that file, Remotion looks for either:
process.env.AWS_ACCESS_KEY_ID/process.env.REMOTION_AWS_ACCESS_KEY_ID,or
credentials you pass in as acredentialsobject.
process.env.AWS_ACCESS_KEY_ID/process.env.REMOTION_AWS_ACCESS_KEY_ID,or
credentials you pass in as acredentialsobject.
The trouble is thatin the environment,process.envdoes not exist. Even though you canDeno.env.get("REMOTION_AWS_ACCESS_KEY_ID"), that doesn’t set a Nodeprocess.envvariable for Remotion to find.
Why passingcredentials: {...}sometimes still doesn’t help
Youarepassing:
────────────────────────────────────────────────────────────────────
jsCopy codecredentials: {
accessKeyId: awsAccessKeyId,
secretAccessKey: awsSecretKey,
region: awsRegion,
},
which should theoretically bypass the environment-variable check. In many Node deployments, that works fine.
However, when importing from Remotion’s bundling sometimes still runs the “environment variable” check first (depending on the version, or if some code path attempts to read region from the environment). In other words, the library can incorrectly fail before it even gets to use yourcredentialsobject.
- Supabase Edge Functions “Secrets” ≠ Node environment variables
When you add secrets in , you can retrieve them usingDeno.env.get(...), but that doesnotautomatically create environment variables that Remotion-Lambda can read (since it tries to readprocess.env). just exposes them through theDeno.envAPI. So if Remotion is coded to doprocess.env.AWS_ACCESS_KEY_ID process.env.REMOTION_AWS_ACCESS_KEY_ID, it’ll come up empty in a environment, unless the library code respects thecredentialsyou passed.
Ways to fix or work around
A) Use Remotion’s credentials API (if available)beforecallingrenderMediaOnLambda
In the latest Remotion versions, there is a function like:
────────────────────────────────────────────────────────────────────
tsCopy codeimport {setAwsCredentials} from '@remotion/lambda';
// Then call this:
setAwsCredentials({
region: 'us-east-1',
accessKeyId: 'ABC...',
secretAccessKey: 'XYZ...',
});
and after that, callrenderMediaOnLambda({...})withoutrepeating thecredentialsobject in the render call. This sets them in an internal location that Remotion will definitely pick up.
However, because you’re pulling fromesm.shand using , you may find that this function is not exported or not working exactly as in Node. If that’s the case, see the next suggestions.
B) Manually inject environment variables at runtime(less ideal)
You could forcibly populateprocess.envfromDeno.envbeforeimporting Remotion. For example,ifSupabase Edge Functions allowed mutatingprocess.envorglobalThis.process.env(which in many environments is read-only, or nonexistent). Typically, you’d do something like:
────────────────────────────────────────────────────────────────────
jsCopy code// Hacky approach:
// Because Remotion checks process.env, we artificially create a process.env
globalThis.process = { env: {} }; // if it doesn't exist
process.env.AWS_ACCESS_KEY_ID = Deno.env.get('REMOTION_AWS_ACCESS_KEY_ID');
process.env.AWS_SECRET_ACCESS_KEY = ');
process.env.AWS_REGION = Deno.env.get('REMOTION_AWS_REGION');
// Then import Remotion
import { renderMediaOnLambda } from ;
// ...
But this depends heavily on whether Supabase Edge Functions / Deno will let you do it. Many times, Edge Functions are read-only so you can’t mutate the global scope orprocess.env.
C) Only run Remotion in Node (a non-Edge environment)
Because Remotion Lambda’s tooling is very Node-centric, some people end up running these calls from a Node-based server or from GitHub Actions (etc.) instead of from an Edge environment. Then you can set standard environment variables (or pass credentials in the standard Node way) and the library will be happy.
In other words, “don’t runrenderMediaOnLambdafrom Deno.” Instead, have your Edge Function queue a job or make an RPC call to a Node server that then calls Remotion.
Summary
Why the error?Because Remotion 4.x is not seeingAWS_ACCESS_KEY_ID/REMOTION_AWS_ACCESS_KEY_IDinprocess.envand is also not picking up yourcredentialsobject the way it should in .
How to fix?Ideally, if Remotion’ssetAwsCredentials()is available, use thatbeforecallingrenderMediaOnLambda.Or you have to so the library sees the variables.Or run your “renderMediaOnLambda” call in a Node environment instead of an Edge Function.
Ideally, if Remotion’ssetAwsCredentials()is available, use thatbeforecallingrenderMediaOnLambda.
Or you have to so the library sees the variables.
Or run your “renderMediaOnLambda” call in a Node environment instead of an Edge Function.
Why the error?Because Remotion 4.x is not seeingAWS_ACCESS_KEY_ID/REMOTION_AWS_ACCESS_KEY_IDinprocess.envand is also not picking up yourcredentialsobject the way it should in .
How to fix?
Ideally, if Remotion’ssetAwsCredentials()is available, use thatbeforecallingrenderMediaOnLambda.
Or you have to so the library sees the variables.
Or run your “renderMediaOnLambda” call in a Node environment instead of an Edge Function.
Ideally, if Remotion’ssetAwsCredentials()is available, use thatbeforecallingrenderMediaOnLambda.
Or you have to so the library sees the variables.
Or run your “renderMediaOnLambda” call in a Node environment instead of an Edge Function.
Most people in a environment take approachAorC, because patchingprocess.envis a bit hacky (and might not be allowed on Supabase Edge Functions).
Try removingregionat the top level and lettingcredentials.regionhandle it
One last thing worth trying: In some older versions of Remotion, specifying both a top-levelregionandcredentials.regioncan cause it to still require an environment variable. If you remove the top-levelregionparam and only specifycredentials: { region: awsRegion, ... }, that might also solve the problem in certain versions of Remotion:
────────────────────────────────────────────────────────────────────
jsCopy codeawait renderMediaOnLambda({
functionName,
serveUrl,
composition: "VideoPreview",
inputProps: {...},
codec: "h264",
credentials: {
accessKeyId: awsAccessKeyId,
secretAccessKey: awsSecretKey,
region: awsRegion,
},
// Remove top-level "region" here
});
But if that doesn’t work, you probably need to use thesetAwsCredentials()approach or move the render code to a Node environment.
In short, the reason you see “but have not set environment variables” even though you are reading them fromDeno.env.get(...)is thatRemotion is checking Node’sprocess.env, which does not exist in Supabase Edge. You either have to patch it, or rely on Remotion’s built-insetAwsCredentials()function (if exported in your build), or else run Remotion from a more traditional Node environment.