Bucket policy exceeds size limit
Error: An error occurred (PolicyTooLarge) when calling the PutBucketPolicy operation: Policy exceeds the maximum allowed document size.
This error occurs when the bucket policy exceeds the 20KB size limit allowed by MinIO. It typically happens when trying to add complex policies or when unnecessary data bloats the policy size.
To resolve this issue, you can define a streamlined bucket policy file and apply it correctly within the MinIO container. Follow these steps:
- 
Create a bucket policy JSON file
- 
On your local machine, create a file named 
bucket-policy.jsonwith the following content: - Save this file in an accessible location.
 
 - 
On your local machine, create a file named 
 - Set up and apply the policy
 
IMPORTANT
Make sure to execute all the
Make sure to execute all the
mc commands within the MinIO container (either by attaching to it or using docker exec).- 
Configure MinIO alias:
Replace
plane-plane-minio:9000with your MinIO server address. - 
Tag existing objects:
 - 
Copy the policy file to the MinIO container:
Replace
<minio-container-id>with the actual ID of your MinIO container. You can find the container ID by runningdocker ps. - 
Apply the policy to the bucket:
 
- 
Verification
- 
Verify that objects are correctly tagged:
 - 
Test public access using:
 
 - 
Verify that objects are correctly tagged:
 
Notes
- Verify that the 
access-keyandsecret-keyused for setting up the alias have adequate permissions to manage the bucket. - If your MinIO server is hosted on a different machine or address, replace 
plane-plane-minio:9000with the appropriate server URL. - After applying the policy, test the setup to confirm it is working as expected.
 

