aws sdk – Awssdk in c++ ignores Legal Hold Locks of the MinIO s3 store
I have a object on a MinIO s3 Object Store and want to lock it with a Legal Hold so that I cannot overwrite it in c++.
I set the Legal Hold like that:
Aws::S3::Model::PutObjectLegalHoldRequest request;
request.SetBucket(bucketName);
request.SetKey(manag_file_name);
Aws::S3::Model::ObjectLockLegalHold lock;
lock.SetStatus(Aws::S3::Model::ObjectLockLegalHoldStatus::ON);
request.SetLegalHold(lock);
auto outcome = minio_client->PutObjectLegalHold(request);
if (!outcome.IsSuccess())
{
std::cout << "Error setting lock status: " << outcome.GetError().GetMessage() << std::endl;
}
I overwrite the same file like that:
Aws::S3::Model::PutObjectRequest in_request;
in_request.SetBucket(bucketName);
in_request.SetKey(manag_file_name);
in_request.SetBody(in_stream);
in_request.SetContentLength(in_mem_size);
auto in_outcome = minio_client->PutObject(in_request);
if (!in_outcome.IsSuccess())
{
std::cout << "Error: " << in_outcome.GetError().GetMessage() << " size: " << in_mem_size << std::endl;
}
And I am successful, even though I locked the file!
I can also delete the file via the Awssdk, ignoring the Legal Hold. But if I try to delete the file in the MinIO Console I get a WORM error:
Object, ‘1_1_0’ is WORM protected and cannot be overwritten
So the Legal Hold is there but Awssdk kind of ignores it?
Read more here: Source link