티스토리 뷰

공부

[aws] s3 delete files

승가비 2023. 1. 6. 23:12
728x90
S3=s3://bucket/asdf/

aws s3 rm ${S3} --recursive

BUCKET=`echo ${S3} | egrep -o 's3://[^/]*' | sed -e s/s3:\\\\/\\\\///g`
PREFIX=`echo ${S3} | sed -e s/s3:\\\\/\\\\/${BUCKET}\\\\///g`

aws s3api list-object-versions \
    --bucket ${BUCKET} \
    --prefix ${PREFIX} |
    jq -r '.Versions[] | .Key + " " + .VersionId' |
        while read key id ; do
            aws s3api delete-object \
                --bucket ${BUCKET} \
                --key ${key} \
                --version-id ${id} >> versions.txt
        done

aws s3api list-object-versions \
    --bucket ${BUCKET} \
    --prefix ${PREFIX} |
    jq -r '.DeleteMarkers[] | .Key + " " + .VersionId' |
        while read key id ; do
            aws s3api delete-object \
                --bucket ${BUCKET} \
                --key ${key} \
                --version-id ${id} >> delete_markers.txt
        done

https://stackoverflow.com/questions/29809105/how-do-i-delete-a-versioned-bucket-in-aws-s3-using-the-cli/74995498#74995498

 

How do I delete a versioned bucket in AWS S3 using the CLI?

I have tried both s3cmd: $ s3cmd -r -f -v del s3://my-versioned-bucket/ And the AWS CLI: $ aws s3 rm s3://my-versioned-bucket/ --recursive But both of these commands simply add DELETE markers t...

stackoverflow.com

https://stackoverflow.com/questions/29809105/how-do-i-delete-a-versioned-bucket-in-aws-s3-using-the-cli

 

How do I delete a versioned bucket in AWS S3 using the CLI?

I have tried both s3cmd: $ s3cmd -r -f -v del s3://my-versioned-bucket/ And the AWS CLI: $ aws s3 rm s3://my-versioned-bucket/ --recursive But both of these commands simply add DELETE markers t...

stackoverflow.com

https://cloud.yandex.com/en/docs/storage/operations/objects/delete-all

 

Yandex

Finds everything

cloud.yandex.com

https://docs.aws.amazon.com/cli/latest/reference/s3api/delete-object.html

 

delete-object — AWS CLI 1.27.45 Command Reference

Note: You are viewing the documentation for an older major version of the AWS CLI (version 1). AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. F

docs.aws.amazon.com

 

728x90
댓글