diff --git a/apps/docs/docs/self-hosting/configuration.md b/apps/docs/docs/self-hosting/configuration.md index 483582a4458..8664e68aef9 100644 --- a/apps/docs/docs/self-hosting/configuration.md +++ b/apps/docs/docs/self-hosting/configuration.md @@ -147,35 +147,7 @@ Used for uploading images, videos, etc... It can be any S3 compatible object sto Note that for AWS S3, your endpoint is usually: `s3..amazonaws.com` -Your bucket must have the following policy that tells S3 to allow public read when an object is located under the public folder: - -```json -{ - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "PublicRead", - "Effect": "Allow", - "Principal": "*", - "Action": "s3:GetObject", - "Resource": "arn:aws:s3:::/public/*" - } - ] -} -``` - -You also need to configure CORS so that an object can be uploaded from the browser: - -```json -[ - { - "AllowedHeaders": ["*"], - "AllowedMethods": ["PUT", "POST"], - "AllowedOrigins": ["*"], - "ExposeHeaders": ["ETag"] - } -] -``` +In order to function properly, your S3 bucket must be configured. Make sure to read through the [S3 configuration](./guides/s3) doc. ## Giphy (GIF picker) diff --git a/apps/docs/docs/self-hosting/guides/s3.md b/apps/docs/docs/self-hosting/guides/s3.md new file mode 100644 index 00000000000..11c6dbdeefb --- /dev/null +++ b/apps/docs/docs/self-hosting/guides/s3.md @@ -0,0 +1,117 @@ +# S3 configuration + +In order for Typebot to store your uploaded files, you need to configure an S3 bucket. + +You can use any S3-compatible storage provider. Here are some examples: + +- [AWS S3](https://aws.amazon.com/s3/) +- [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces/) +- [Wasabi](https://wasabi.com/) +- [MinIO](https://min.io/) + +:::note +If you are self-hosting using Docker, you can follow the [docker-specific instructions](./docker#s3-storage) to run a local S3-compatible storage server. +::: + +To function properly, your S3 bucket must have the following configuration: + +- CORS policy: + + ```json + { + "CORSRules": [ + { + "AllowedOrigins": ["*"], + "AllowedMethods": ["GET"], + "AllowedHeaders": ["*"], + "MaxAgeSeconds": 3000 + } + ] + } + ``` + +- Access policy: + ```json + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "PublicRead", + "Effect": "Allow", + "Principal": "*", + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::/public/*" + } + ] + } + ``` + +## How to set up CORS policy? + +Some S3 providers like AWS provide a user interface that allows you to directly enter a bucket policy. However, other providers might not provide such an interface. In this case, you can set up the CORS policy from the command line. + +1. Make sure you have the AWS CLI (Command Line Interface) installed and configured on your machine. If you haven't done so already, refer to the official AWS CLI documentation for installation and configuration instructions. + +2. Open your command-line interface (CLI), such as Terminal on macOS or Command Prompt on Windows. + +3. Create a JSON file (e.g., cors-policy.json) that contains the desired CORS policy. Here's an example CORS policy that allows GET requests from all origins (\*): + + ```json + { + "CORSRules": [ + { + "AllowedOrigins": ["*"], + "AllowedMethods": ["GET"], + "AllowedHeaders": ["*"], + "MaxAgeSeconds": 3000 + } + ] + } + ``` + +4. Run the following command, replacing `` with the name of your S3 bucket and `` with the file path to your JSON CORS policy file: + + ```bash + aws s3api put-bucket-cors --bucket --cors-configuration file:// + ``` + + When the command is executed successfully, AWS will respond with the JSON representation of the CORS configuration. This indicates that the CORS policy has been applied to your S3 bucket. + + Note: Ensure that you have the appropriate AWS credentials and permissions to perform this action. + +## How to set up Access policy? + +Some S3 providers like AWS provide a user interface that allows you to directly enter a bucket policy. However, other providers like DigitalOcean do not provide such a user interface. In this case, you can set up a bucket policy from the command line. + +To set up an S3 bucket policy from the command line, you can use the AWS Command Line Interface (CLI). Here's a step-by-step guide: + +1. Install and configure the AWS CLI on your machine if you haven't done so already. You can refer to the official AWS CLI documentation for instructions on installation and configuration. + +2. Open your command-line interface (e.g., Terminal on macOS or Command Prompt on Windows). + +3. To set up a bucket policy, you need the policy document in JSON format. Create a JSON file (e.g., bucket-policy.json) containing the desired policy. Here's an example policy that allows Public read access for all objects within the bucket: + +```json +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "PublicRead", + "Effect": "Allow", + "Principal": "*", + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::/public/*" + } + ] +} +``` + +4. Replace `` with the name of your S3 bucket. + +5. Run the following command, replacing `` with the name of your S3 bucket and `` with the file path to your JSON policy document: + + ```bash + aws s3api put-bucket-policy --bucket --policy file:// + ``` + + After running the command, AWS will respond with the policy's JSON representation if the operation is successful. You should see the response output confirming the policy has been added to the bucket.