🎥 Make videos programmatically with React
`@remotion/lambda`: Allow skipping the credentials check
Jonny Burgerc3d293f81447
diff --git a/packages/docs/docs/lambda/authentication.mdx b/packages/docs/docs/lambda/authentication.mdxindex d488073a74..6549118dd5 100644--- a/packages/docs/docs/lambda/authentication.mdx+++ b/packages/docs/docs/lambda/authentication.mdx@@ -90,7 +90,17 @@ process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK = "1";```Remotion will not check the credentials and will not throw an error if they are not set.-However, if there is a misconfiguration, you may still get an error from the AWS SDK.+However, if there is a misconfiguration, you may still get an error from the AWS SDK.+Also read the note about [caching clients](#disable-caching).++## Disable caching<AvailableFrom v="4.0.160"/>++AWS clients are cached to save memory and speed up initialization.+The cache key is based on the credentials and the region.++If you opted out of [the credentials check](#skipping-the-credentials-check), the instance is cached for the lifetime of the process.+If you want to disable the cache, set the `REMOTION_SKIP_AWS_CREDENTIALS_CHECK` environment variable to any value.+It's unlikely you need to set this value. This is only if you change the way you authenticate between API calls.## See alsodiff --git a/packages/lambda/src/shared/aws-clients.ts b/packages/lambda/src/shared/aws-clients.tsindex 6b4920f22a..3a680e540f 100644--- a/packages/lambda/src/shared/aws-clients.ts+++ b/packages/lambda/src/shared/aws-clients.ts@@ -104,7 +104,11 @@ const getCredentialsHash = ({}): string => {const hashComponents: {[key: string]: unknown} = {};- if (process.env.REMOTION_AWS_PROFILE) {+ if (process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK) {+ hashComponents.credentials = {+ credentialsSkipped: true,+ };+ } else if (process.env.REMOTION_AWS_PROFILE) {hashComponents.credentials = {awsProfile: process.env.REMOTION_AWS_PROFILE,};@@ -202,24 +206,30 @@ export const getServiceClient = <T extends keyof ServiceMapping>({if (!_clients[key]) {checkCredentials();- if (customCredentials) {- _clients[key] = new Client({- region: customCredentials.region ?? 'us-east-1',- credentials:- customCredentials.accessKeyId && customCredentials.secretAccessKey- ? {- accessKeyId: customCredentials.accessKeyId,- secretAccessKey: customCredentials.secretAccessKey,- }- : undefined,- endpoint: customCredentials.endpoint,- });- } else {- _clients[key] = new Client({- region,- credentials: getCredentials(),- });+ const client = customCredentials+ ? new Client({+ region: customCredentials.region ?? 'us-east-1',+ credentials:+ customCredentials.accessKeyId && customCredentials.secretAccessKey+ ? {+ accessKeyId: customCredentials.accessKeyId,+ secretAccessKey: customCredentials.secretAccessKey,+ }+ : undefined,+ endpoint: customCredentials.endpoint,+ })+ : process.env.REMOTION_SKIP_AWS_CREDENTIALS_CHECK+ ? new Client({region})+ : new Client({+ region,+ credentials: getCredentials(),+ });++ if (process.env.REMOTION_DISABLE_AWS_CLIENT_CACHE) {+ return client as ServiceMapping[T];}++ _clients[key] = client;}return _clients[key] as ServiceMapping[T];