Saltar al contenido

Delete object only with standard storage class in S3

0

I have an S3 bucket containing 7 TB of data, with approximately 6 TB stored in the Standard storage class (around 40 million objects) and the rest in Glacier. I need to delete all objects in the Standard storage class while retaining those in Glacier. Since the objects are randomly distributed within the bucket, there is no specific folder to target for Standard storage class objects, making lifecycle rules unsuitable for this task.

can somebody suggest an efficient and straightforward approach to achieve this?

Thanks!

1 Respuesta
0

A simple shell script should work

List objects with storage class

aws s3api list-objects --bucket YOUR_BUCKET_NAME --query "Contents[?StorageClass=='STANDARD'].[Key]" --output text

Delete only standard class objects

aws s3api list-objects --bucket YOUR_BUCKET_NAME --query "Contents[?StorageClass=='STANDARD'].[Key]" --output text | xargs -I {} aws s3 rm s3://YOUR_BUCKET_NAME/{}

Please test before performing in your Bucket

EXPERTO
respondido hace 10 meses
EXPERTO
revisado hace 10 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.