Delete an object in AWS S3 - amazon-web-services

I'm trying to understand the delete operation of an object in aws S3.
In cross region replication, if I delete an object from the source, this delete is not propagated to the destination.
The official text - "If you specify an object version ID to delete in
a DELETE request, Amazon S3 deletes that object version in the source
bucket, but it doesn't replicate the deletion in the destination
bucket. In other words, it doesn't delete the same object version from
the destination bucket. This protects data from malicious deletions. "
In other case, I read that
The official text - Amazon S3 offers eventual consistency for
overwrite PUTS and DELETES in all Regions
When I made a test, the delete is not propagated. Then, there is a divergence between the replica !
Is it normal ? how about the eventual consistency of the delete ?

This is not about replication, it's about simple buckets from Introduction to AWS S3.
Amazon S3 offers eventual consistency for overwrite PUTS and DELETES in all Regions
The right answer - "it doesn't delete the same object version from the destination bucket. This protects data from malicious deletions".
If you need "consistency of the delete" - you can try to automate it with aws s3 sync with --delete flag.

Related

How do I move an S3 "Deep Glacier Archive" object?

I have a number of "Deep Glacier Archive" class objects in the root level of my Amazon S3 bucket.
As the number of objects grows, I've added some top-level folders to the same bucket that I'd like to move the other objects into for organizational reasons. While I can add new objects to these folders, I've noticed that the "Move" action option is grayed out while when I have existing objects selected.
Is there a way that I can move these glacier objects into the other folders in the same bucket? (I'm using the Amazon AWS S3 web console interface.)
Objects cannot be 'moved' in Amazon S3. Doing so actually involves performing a copy and then delete.
The S3 management console is unable to move/copy an object with a Glacier storage class because the data is not immediately available. Instead, you should:
Restore the object (Charges might apply)
Once restored, perform the move/copy
You have to first restore the objects and wait around 48h until the process completes (you can do that directly from the management console). Once it is done you should see the download button enabled in the console and a countdown of the days you set them to be available.
Then you can move them using the AWS CLI with:
aws s3 mv "s3://SOURCE" "s3://DEST" --storage-class DEEP_ARCHIVE --force-glacier-transfer
I don't think is possible to move them from the management console directly, after the restoration.

Delete S3 Object(all versions) from primary bucket while replicating it to cross region bucket

We have a use case where our application upload backups to s3 bucket and same has been replicate to cross region bucket for disaster recovery.
Sometime backup fail to upload complete backup. In such case we have to delete already uploaded backup. But I am curious about the replication. If I am going to delete object which is currently actively replicating(in progress replication) to cross region, will it be possible to delete that object or will have to wait until complete replication of that object.
If its possible to delete object which is now replicating then what will happen to destination bucket object which is partially replicated. It should be manually deleted or how to do stuff with that?

What happens if I delete an S3 object before replication?

Long time listener, first time caller...
If I have an S3 bucket which is versioned (as per the documentation for replication) and bucket replication is enabled; what happens if the source bucket object is deleted before replication has taken place?
I'm assuming (as the source bucket is versioned) the replication will still take place. The replication logic surely sees a new object creation event and replicates this in the destination bucket. Because I've not specified any other configuration, the delete marker subsequently placed on the source bucket object will not be replicated onto the destination object. Therefore it should just appear as normal in the destination bucket and not be visible in the source bucket.
I can't find anything concrete in the documentation that clarifies the position on this situation.
It depends on which option you choose in your replication configuration:
V1: the delete marker is replicated - a subsequent GET request to the deleted object does not return the object in either the source or the destination bucket.
V2: the delete marker is not replicated - a subsequent GET request to the deleted object returns the object only in the destination bucket.
For more, see Managing delete marker replication in Amazon S3.

backing up s3 buckets best practice

I want to do a daily backup for s3 buckets. I was wondering if anyone knew what was best practice?
I was thinking of using a lambda function to copy contents from one s3 bucket to another as the s3 bucket is updated. But that won't mitigate against an s3 failure. How do I copy contents from one s3 bucket to another Amazon service like Glacier using lamda? What's the best practice here for backing up s3 buckets?
NOTE: I want to do a backup not archive (where content is deleted afterward)
Look into S3 cross-region replication to keep a backup copy of everything in another S3 bucket in another region. Note that you can even have the destination bucket be in a different AWS Account, so that it is safe even if your primary S3 account is hacked.
Note that a combination of Cross Region Replication and S3 Object Versioning (which is required for replication) will allow you to keep old versions of your files available even if they are deleted from the source bucket.
Then look into S3 lifecycle management to transition objects to Glacier to save storage costs.

Lifecycle policy on S3 bucket

I have an S3 bucket on which I've configured a Lifecycle policy which says to archive all objects in the bucket after 1 day(s) (since I want to keep the files in there temporarily but if there are no issues then it is fine to archive them and not have to pay for the S3 storage)
However I have noticed there are some files in that bucket that were created in February ..
So .. am I right in thinking that if you select 'Archive' as the lifecycle option, that means "copy-to-glacier-and-then-delete-from-S3"? In which case this issue of the files left from February would be a fault - since they haven't been?
Only I saw there is another option - 'Archive and then Delete' - but I assume that means "copy-to-glacier-and-then-delete-from-glacier" - which I don't want.
Has anyone else had issues with S3 -> Glacier?
What you describe sounds normal. Check the storage class of the objects.
The correct way to understand the S3/Glacier integration is the S3 is the "customer" of Glacier -- not you -- and Glacier is a back-end storage provider for S3. Your relationship is still with S3 (if you go into Glacier in the console, your stuff isn't visible there, if S3 put it in Glacier).
When S3 archives an object to Glacier, the object is still logically "in" the bucket and is still an S3 object, and visible in the S3 console, but can't be downloaded from S3 because S3 has migrated it to a different backing store.
The difference you should see in the console is that objects will have A "storage class" of Glacier instead of the usual Standard or Reduced Redundancy. They don't disappear from there.
To access the object later, you ask S3 to initiate a restore from Glacier, which S3 does... but the object is still in Glacier at that point, with S3 holding a temporary copy, which it will again purge after some number of days.
Note that your attempt at saving may be a little bit off target if you do not intend to keep these files for 3 months, because any time you delete an object from Glacier, you are billed for the remainder of the three months, if that object has been in Glacier for a shorter time than that.