Are s3 prefixes deleted by the lifecycle management? - amazon-s3

Are (empty) prefixes also deleted by the s3 lifecycle management?

S3 is a glorious hash table of (key, value) pairs. The presence of '/' in the key gives the illusion of folder structure and the S3 web UI also organizes the keys in a hierarchy. So, if lifecycle management rules end up deleting all the keys with a certain prefix, then it essentially means the prefix is also deleted (basically, there is no key with such a prefix). HTH.

Short answer: yes
More detail: prefix are just 0-byte object. When you use the Amazon S3 console to create a folder, Amazon S3 creates a 0-byte object with a key that's set to the folder name that you provided. For example, if you create a folder named photos in your bucket, the Amazon S3 console creates a 0-byte object with the key photos/. The console creates this object to support the idea of folders.How S3 supports folder idea

Related

How is it possible to have folders in object storage? [duplicate]

This question already has answers here:
Add folder in Amazon s3 bucket
(16 answers)
Closed last month.
As per my understanding, object storage has a 'flat' structure so you cannot create folders within buckets. However, in both GCP & AWS, I am able to upload regular folders to the buckets, which also look like regular folders on their web UI console. What is the difference between the folders I am seeing on these buckets, and the folders which are there in a file-storage system (like my personal laptop)?
As far as I know Object Storage has a 'flat' structure so you cannot create folders within buckets, nor can you nest buckets in buckets.
If you need to have some form of 'folder'-like structure, then using prefixes is the way to go. You'll then end up with this structure: {endpoint}/{bucket-name}/{object-prefix}/{object-name}.
thats what you are seeing according to me
Amazon S3 has a flat structure instead of a hierarchy as you would see in a file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects. It does this by using a shared name prefix for objects (that is, objects have names that begin with a common string). Object names are also referred to as key names.
For example, you can create a folder on the console named photos and store an object named myphoto.jpg in it. The object is then stored with the key name photos/myphoto.jpg, where photos/ is the prefix.
Here are two more examples:
If you have three objects in your bucket—logs/date1.txt,
logs/date2.txt, and logs/date3.txt—the console will show a folder
named logs. If you open the folder in the console, you will see three
objects: date1.txt, date2.txt, and date3.txt.
If you have an object named photos/2017/example.jpg, the console will
show you a folder named photos containing the folder 2017. The folder
2017 will contain the object example.jpg.
When you create a folder in Amazon S3, S3 creates a 0-byte object with a key that's set to the folder name that you provided. For example, if you create a folder named photos in your bucket, the Amazon S3 console creates a 0-byte object with the key photos/. The console creates this object to support the idea of folders.
You can read more in the Amazon S3 user guide.

AWS S3 make folder IFA forever

In aws s3 web interface we can select a specific folder then navigate to properties and select IFA... like this
This will start processing all existing data, but if you open the same properties page again its not selected. If you select again and apply it will show a processing bar again...
Its ambiguous does that folder remain IFA once selected and saved? will future uploads to that folder stored in IFA storage? If not how do we do that?
I know that there is migration rule like after 30 days move to IFA but i know upfront that my data is suitable for IFA storage...
"For all selected items" means the current objects, not the folders.
The folders do not exist in S3 in any meaningful sense yes, you can "create" a folder but all that does is create a placeholder for convenience in the console -- there are never any files actually "in" the folder -- so it is impossible to actually set any kind of properties on them. The folders that appear in the console are just a human-friendly representation of a hierarchy, created by splitting the keys on / delimiters.
In Amazon S3, buckets and objects are the primary resources, where objects are stored in buckets. Amazon S3 has a flat structure with no hierarchy like you would see in a typical file system. However, for the sake of organizational simplicity, the Amazon S3 console supports the folder concept as a means of grouping objects.
http://docs.aws.amazon.com/AmazonS3/latest/UG/FolderOperations.html
If you want objects stored for their lifetime as either STANDARD_IA or REDUCED_REDUNDANCY then you have to initially upload them that way. If you want them to transition to STANDARD_IA or GLACIER later, then you use lifecycle policies.
Note also that changing storage classes in the console like you are doing incurs the same cost as re-uploading the object, because changing storage classes is accomplished by the console invoking the S3 copy operation -- using the same key for source and destination. It's $0.01 per 1000 objects, so use it wisely on large collections of objects. Objects and their metadata are immutable, so modifying them (including storage class, which isn't technically metadata) requires replacing the object with an identical object.

Exclude specific files from S3 Cross-Region Replication

I was wondering if there was a way to exclude specific files from S3 Cross-Region Replication. I am aware of the prefix option, but I have a cache folder within my bucket that I don't want to include.
Example:
I want to include the following:
images/production/image1/file.jpg
But I don't want to include this:
images/production/image1/cache/file.jpg
Seems you need to play with objects/bucket rights in order to exclude certain objects from replication:
Amazon S3 will replicate only objects in the source bucket for which
the bucket owner has permission to read objects and read ACLs
and
Amazon S3 will not replicate objects in the source bucket for which
the bucket owner does not have permissions
Maybe will be easier to move cache data in a separate bucket.
I know it's an old post but I thought it might be worth updating it with an answer that does not require meddling with the permissions.
According to Amazon's own documentation (https://docs.aws.amazon.com/AmazonS3/latest/dev/crr-how-setup.html) you can choose the objects (using a prefix in the object name or filtering by tags) that will be replicated in the Replication Configuration for the bucket:
The objects that you want to replicate—You can replicate all of the objects in >the source bucket or a subset. You identify subset by providing a key name >prefix, one or more object tags, or both in the configuration. For example, if >you configure cross-region replication to replicate only objects with the key >name prefix Tax/, Amazon S3 replicates objects with keys such as Tax/doc1 or >Tax/doc2, but not an object with the key Legal/doc3. If you specify both prefix >and one or more tags, Amazon S3 replicates only objects having specific key >prefix and the tags.
For instance, to use a prefix, set the following rule in your CRR configuration (https://docs.aws.amazon.com/AmazonS3/latest/dev/crr-add-config.html):
<Rule>
...
<Filter>
<Prefix>key-prefix</Prefix>
</Filter>

Folder won't delete on Amazon S3

I'm trying to delete a folder created as a result of a MapReduce job. Other files in the bucket delete just fine, but this folder won't delete. When I try to delete it from the console, the progress bar next to its status just stays at 0. Have made multiple attempts, including with logout/login in between.
I had the same issue and used AWS CLI to fix it:
aws s3 rm s3://<your-bucket>/<your-folder-to-delete>/ --recursive ;
(this assumes you have run aws configure and aws s3 ls s3://<your-bucket>/ already works)
First and foremost, Amazon S3 doesn't actually have a native concept of folders/directories, rather is a flat storage architecture comprised of buckets and objects/keys only - the directory style presentation seen in most tools for S3 (including the AWS Management Console itself) is based solely on convention, i.e. simulating a hierarchy for objects with identical prefixes - see my answer to How to specify an object expiration prefix that doesn't match the directory? for more details on this architecture, including quotes/references from the AWS documentation.
Accordingly, your problem might stem from a tool using a different convention for simulating this hierarchy, see for example the following answers in the AWS forums:
Ivan Moiseev's answer to the related question Cannot delete file from bucket, where he suggests to use another tool to inspect whether you might have such a problem and remedy it accordingly.
The AWS team response to What are these _$folder$ objects? - This is a convention used by a number of tools including Hadoop to make directories in S3. They're primarily needed to designate empty directories. One might have preferred a more aesthetic scheme, but well that is the way that these tools do it.
Good luck!
I was getting the following error when I tried to delete a bucket which was a directory that held log files from Cloudfront.
An unexpected error has occurred. Please try again later.
After I disabled logging in Cloudfront I was able to delete the folder successfully.
My guess is that it was a system folder used by Cloudfront that did not allow deletion by the owner.
In your case, you may want to check if MapReduce is holding on to the folder in question.
I was facing the same problem. Tried many login, logout attempts and refresh but problem persist. Searched stackoverflow and found suggestions to cut and paste folder in different folder then delete but didn't worked.
Another thing you should look is for versioning that might effect your bucket may be suspending the versioning allow you to delete the folder.
My solution was to delete it with code. I have used boto package in python for file handling over s3 and the deletion worked when I tried to delete that folder from my python code.
import boto
from boto.s3.key import Key
keyId = "your_aws_access_key"
sKeyId = "your_aws_secret_key"
fileKey="dummy/foldertodelete/" #Name of the file to be deleted
bucketName="mybucket001" #Name of the bucket, where the file resides
conn = boto.connect_s3(keyId,sKeyId) #Connect to S3
bucket = conn.get_bucket(bucketName) #Get the bucket object
k = Key(bucket,fileKey) #Get the key of the given object
k.delete() #Delete
S3 doesn't keep directory it just have a flat file structure so everything is managed with key.
For you its a folder but for S3 it just an key.
If you want to delete a folder named -> dummy
then key would be
fileKey = "/dummy/"
Firstly, read the content of directory from getBucket method, then you got a array list of all files, then delete the file from deleteObject method.
if (($contents = $this->S3->getBucket(AS_S3_BUCKET, "file_path")) !== false)
{
foreach ($contents as $file)
{
$result = $this->S3->deleteObject(AS_S3_BUCKET,$file['name']);
}
}
$this->S3 is S3 class object, and AS_S3_BUCKET is bucket name.

How to create folder on Amazon S3 using objective-c

I know this is a question that may have been asked before (at least in Python), but I am still struggling to get this right. I compare my local folder structure and content with what I have stored in my Amazon S3 bucket. The directories not exisiting on S3, but which are found locally, are to be created in my S3 bucket. It seems that Amazon S3 does not have the concept of a folder, but rather a folder is identified as an empty file of size 0. My question is, how can I easily create a folder in objective-c by putting an empty file (with name correspoding to the folder name) on S3 (I use ASIHTTP for my get and put events)? I want to create the directory explicitly and not implicitly by copying a new file to a non-exisiting folder. I appreciate your help on this.
It seems that Amazon S3 does not have the concept of a folder, but rather a folder is identified as an empty file of size 0
The / character is often used as a delimiter, when keys are used as pathnames. To make a folder called bar in the parent folder foo, create a key with the name /foo/bar/.
Amazon now has an AWS SDK for Objective C. The S3PutObjectRequest class has the method -initWithKey:inBucket:.