Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change storage class of object in s3 bucket?

I need to change storage class of a s3 object from STANDARD class into STANDARD_IA using s3cmd. Can anybody help me to do this task. Thanks in advance.

like image 886
Gugan Abu Avatar asked Mar 21 '16 13:03

Gugan Abu


2 Answers

Using s3cmd:

s3cmd cp s3://BUCKET/KEY s3://BUCKET/KEY --storage-class=STANDARD_IA

Using AWS CLI:

aws s3 cp s3://BUCKET/KEY s3://BUCKET/KEY --storage-class STANDARD_IA

WARNING: If Versioning is on, this does not change the storage class of the object. It creates a new object with the requested storage class (e.g. STANDARD_IA), but keeps the original version in whatever storage class it was uploaded (e.g. STANDARD). You'll be paying for both copies.

Two versions of the object with different storage classes

like image 57
Mark B Avatar answered Sep 21 '22 02:09

Mark B


If you want to change the storage class on all objects within a bucket use:

aws s3 cp s3://<bucket-name>/ s3://<bucket-name>/ --recursive --storage-class <storage_class>

--storage-class (string) The type of storage to use for the object. Valid choices are: STANDARD | REDUCED_REDUNDANCY | STANDARD_IA | ONEZONE_IA | INTELLIGENT_TIERING | GLACIER | DEEP_ARCHIVE. Defaults to 'STANDARD'

Source: cp @ AWS CLI Command Reference

like image 41
dpatryas Avatar answered Sep 19 '22 02:09

dpatryas