Dinero
Dinero

Reputation: 1160

Delete files inside a subfolder residing inside a bucket on amazon s3

On my s3 I have a bucket called nba-dataset. Inside the nba-dataset i have a folder called env. Inside the folder env i have another folder called prod-stage.

So basically The path looks like this nba-dataset > env > prod-stage.

I have a files inside prod-stage that I want to delete after x number of days.

So the way i understand is I can apply a lifecycle rule on the bucket nba-dataset.

The confusing part for me is what should the value be for prefix. Would it be env/prod-stage or would it be simply prod-stage?

I would appreciate guidance here as there are many files in the subfolders of the bucket nba-dataset that I don't want to delete by accident. I only want to delete files inside the prod-stage folder that are older than x days.

Upvotes: 1

Views: 1243

Answers (1)

Chris Williams
Chris Williams

Reputation: 35258

The prefix is an absolute path so in your case it is env/prod-stage/.

There is no such thing as a subfolder within S3, each object has a key which the GUI displays as subfolders by splitting the prefix separately by the "/"character.

In fact the interface is simply calling the list-objects method. When you're displayed as being in the env folder the prefix is env, then when you move into the subfolder of prod-stage the prefix becomes env/prod-stage.

Upvotes: 2

Related Questions