Capítulo 467 de 988

Chapter 467: getAwsClient()

Core Idea

This API exposes full access to the AWS SDK that Remotion uses under the hood. You can use it to interact with your AWS infrastructure in ways that Remotion doesn't provide a function for.

Key Concepts

  • Example: Getting a buffer for a render
  • Example: Enable CORS for a bucket
  • Arguments
  • region
  • service
  • customCredentials?<AvailableFrom v="3.2.23" />
  • forcePathStyle?<AvailableFrom v="4.0.202" />
  • Return value

Code Examples

// Import from "@remotion/lambda" instead before Remotion v4.0.60

const bucketName = 'remotionlambda-d9mafgx';

const getFileAsBuffer = async () => {
  const progress = await getRenderProgress({
    renderId: 'd7nlc2y',
    bucketName: 'remotionlambda-d9mafgx',
    functionName: 'remotion-render-la8ffw',
    region: 'us-east-1',
  });

  if (!progress.outKey) {
    // Video not yet rendered
    return;
  }

  const {client, sdk} = getAwsClient({region: 'us-east-1', service: 's3'});

  const data = client.send(
    new sdk.GetObjectCommand({
      Bucket: bucketName,
      Key: progress.outKey,
    }),
  );

  return data.Body as Readable;
};
  • What it demonstrates: Usage pattern for getAwsClient() from the official docs.

Key Takeaways

  1. Understand example: getting a buffer for a render when working with getAwsClient().
  2. Understand example: enable cors for a bucket when working with getAwsClient().
  3. Understand arguments when working with getAwsClient().
  4. Understand region when working with getAwsClient().
  5. Understand service when working with getAwsClient().

Connects To

  • api: related page in the Lambda (@remotion/lambda) section.
  • Approuterwebhook: related page in the Lambda (@remotion/lambda) section.
  • Authentication: related page in the Lambda (@remotion/lambda) section.