Document required S3 bucket policy
This PR attempts to document the required S3 bucket policies required by the Barman Cloud plugin to work as intended.
Relevant documentation:
- https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html#mpuAndPermissions
Doing some trial-and-error, these actions seems to be required:
s3:DeleteObject*s3:GetObjects3:ListBuckets3:PutObject
I've also added these:
s3:AbortMultipartUploads3:ListMultipartUploadParts
I think it would make sense for Barman to utilize mutlipart uploads, but I'm not sure. Perhaps it does its own chunking and never requires large files?
* I've not seen a delete operation first-hand, but everyone I've spoken to seems to agree that retention policy can delete objects.
After a few rounds of discussions and comments, and some trial-and-error on my side, I think this is ready for review.
I'm still not sure if actions for multi-part uploads are required or not. Maintainers help?
I just ran into an error with multipart upload! It is required. I'll add it.
Relevant docs:
- https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html#mpuAndPermissions
Strange, I'm still seeing the same errors:
ERROR: Backup failed uploading data (An error occurred (AccessDenied) when calling the CreateMultipartUpload operation: Access Denied)
ERROR: Backup failed uploading backup.info file (An error occurred (AccessDenied) when calling the PutObject operation: Access Denied)
EDIT: Oops, I had a typo in the username. 🙈 It works for me now, but I'm not 100% confident if the newly added permissions are strictly required or not anymore.
Doing some trial-and-error, these actions seems to be required:
s3:DeleteObject*s3:GetObjects3:ListBuckets3:PutObjectI've also added these:
s3:AbortMultipartUploads3:ListMultipartUploadPartsI think it would make sense for Barman to utilize mutlipart uploads, but I'm not sure. Perhaps it does its own chunking and never requires large files?
- I've not seen a delete operation first-hand, but everyone I've spoken to seems to agree that retention policy can delete objects.
The plugin executes a retention policy that internally relies on Barman Cloud.
As shown in the following code references:
- https://github.com/EnterpriseDB/barman/blob/ff040cd1feee805da3e4662a187c583f8730dfab/barman/cloud_providers/aws_s3.py#L570
- https://github.com/EnterpriseDB/barman/blob/ff040cd1feee805da3e4662a187c583f8730dfab/barman/cloud_providers/aws_s3.py#L711
- https://github.com/EnterpriseDB/barman/blob/ff040cd1feee805da3e4662a187c583f8730dfab/barman/cloud_providers/aws_s3.py#L634
In these sections, methods s3.meta.client.delete_objects(...) and s3.meta.client.delete_object(...) are invoked.
According to the official Boto3 (AWS SDK for Python) documentation:
https://docs.aws.amazon.com/boto3/latest/reference/services/s3/client/delete_objects.html
https://docs.aws.amazon.com/boto3/latest/reference/services/s3/client/delete_object.html
the s3:DeleteObject permission is required to perform these operations.
Hi! Just wanted to +1 this. The docs improvement here would be really helpful for users. Would any maintainer be able to review and merge this? Thanks!