This README file will guide you through configuring an AWS S3 bucket, and running a Node.js script with Puppeteer to execute and interact with a development server. Follow the steps below to get everything up and running.
- Node.js installed on your machine.
- AWS Account with access to create and configure S3 buckets.
- Log in to your AWS Management Console.
- Go to the S3 service and create a new bucket.
- Note down the bucket name and region as you'll need these for configuration.
- Go to the IAM service in the AWS Management Console.
- Create a new IAM user with programmatic access.
- Attach the
AmazonS3FullAccesspolicy to this user to grant full access to S3. - Note down the Access Key ID and Secret Access Key.
-
Go to the S3 bucket you created.
-
Navigate to the Permissions tab.
-
Find the CORS configuration section and add the following CORS rules:
[ { "AllowedHeaders": ["*"], "AllowedMethods": ["GET", "PUT", "HEAD"], "AllowedOrigins": ["*"], "ExposeHeaders": [] } ]This configuration allows your application to make requests to S3 without being blocked by CORS.
Clone the repository to your local machine if you haven’t already:
git clone <repository-url>
cd ./core/examples/puppeteerInstall the required npm dependencies:
npm installCreate a .env file in the root of your project and add the following environment variables:
S3_ACCESS_KEY=YOUR_S3_ACCESS_KEY
S3_SECRET_KEY=YOUR_S3_SECRET_KEY
S3_REGION=YOUR_S3_BUCKET_REGION
S3_BUCKET=YOUR_S3_BUCKET_NAME
S3_FOLDER=YOUR_S3_FOLDER_NAME (default is 'output')
Replace the placeholders with your actual AWS credentials and S3 bucket details.
Execute the main script using tsx to interact with the Vite dev server, render a video, and upload the result to S3:
npm run mainThe relevant script can be found in index.ts, which handles the evaluation of code on the dev server and performs the upload process.
- Set up an S3 bucket and IAM user with appropriate permissions.
- Configure CORS settings for your S3 bucket to allow necessary HTTP methods.
- Create a
.envfile with your AWS credentials and bucket details. - Install project dependencies using
npm install. - Execute the Puppeteer script with
npm run mainto render and upload content.
If you encounter any issues or have questions, refer to the documentation for Diffusion Studio, Vite, Puppeteer, or AWS S3, or feel free to reach out for support.