plugin-barman-cloud icon indicating copy to clipboard operation
plugin-barman-cloud copied to clipboard

Document required S3 bucket policy

Open lindhe opened this issue 10 months ago • 6 comments

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

lindhe avatar Jan 26 '26 16:01 lindhe

Doing some trial-and-error, these actions seems to be required:

  • s3:DeleteObject*
  • s3:GetObject
  • s3:ListBucket
  • s3:PutObject

I've also added these:

  • s3:AbortMultipartUpload
  • s3: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.

lindhe avatar Jan 28 '26 12:01 lindhe

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?

lindhe avatar Jan 29 '26 19:01 lindhe

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

lindhe avatar Jan 30 '26 14:01 lindhe

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.

lindhe avatar Jan 30 '26 14:01 lindhe

Doing some trial-and-error, these actions seems to be required:

  • s3:DeleteObject*
  • s3:GetObject
  • s3:ListBucket
  • s3:PutObject

I've also added these:

  • s3:AbortMultipartUpload
  • s3: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.

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.

sosi-andrea avatar Mar 19 '26 20:03 sosi-andrea

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!

sosi-andrea avatar Apr 21 '26 10:04 sosi-andrea