Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively change storage class on bucket #2056

Closed
kaihendry opened this issue Jul 10, 2016 · 6 comments
Closed

Recursively change storage class on bucket #2056

kaihendry opened this issue Jul 10, 2016 · 6 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information. s3 service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@kaihendry
Copy link

How does one recursively change all objects on a bucket to STANDARD_IA with aws s3?

http://docs.aws.amazon.com/AmazonS3/latest/dev/ChgStoClsOfObj.html

Bonus: A way of defining a default storage class in ~/.aws/config

@kyleknap kyleknap added s3 api-question closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jul 12, 2016
@kyleknap
Copy link
Member

You can do it by running this command:

$ aws s3 cp s3://knapp-standard-ia s3://knapp-standard-ia --recursive --storage-class STANDARD_IA
copy: s3://knapp-standard-ia/foo.py to s3://knapp-standard-ia/foo.py
copy: s3://knapp-standard-ia/100MB to s3://knapp-standard-ia/100MB

And then if you check the contents, the class should be STANDARD_IA:

$ aws s3api list-objects --bucket knapp-standard-ia
{
    "Contents": [
        {
            "LastModified": "2016-07-12T19:37:40.000Z", 
            "ETag": "\"0c4af570340e15f2be9924e70bc34257-13\"", 
            "StorageClass": "STANDARD_IA", 
            "Key": "100MB", 
            "Owner": {
                "DisplayName": "kylekaws", 
                "ID": "876e6c081ece589308db3ea341721492c49ad27397678f075c6deeeb6935a80f"
            }, 
            "Size": 104857600
        }, 
        {
            "LastModified": "2016-07-12T19:37:41.000Z", 
            "ETag": "\"d9ccfaeb76cd014d2551753ac45b8b98\"", 
            "StorageClass": "STANDARD_IA", 
            "Key": "foo.py", 
            "Owner": {
                "DisplayName": "kylekaws", 
                "ID": "876e6c081ece589308db3ea341721492c49ad27397678f075c6deeeb6935a80f"
            }, 
            "Size": 825
        }
    ]
}

I am not sure storage class is something we would want to define in the config file. It is pretty specific. It would need to be something more general like setting default parameters.

Let us know if that helps.

@kaihendry
Copy link
Author

Thanks Kyle, I hope that goes into the man page / documentation as an example.

@diehlaws diehlaws added guidance Question that needs advice or information. service-api This issue is due to a problem in a service API, not the SDK implementation. and removed api-question labels Jan 4, 2019
@m4h
Copy link

m4h commented Apr 24, 2019

@kyleknap,

Sorry for excavating a such old issue.

Just to warn other users who will use a command. The method you supplied will duplicate objects in case if bucket versioning is enabled (hence double the price).

Just curious - where i can submit a request to reduce S3 to S2 (as it is not simple)?

@joesenova
Copy link

WIll this change of storage class charge for data transfer?

@oliveirawro
Copy link

WIll this change of storage class charge for data transfer?

I'm interested in too

@Sekkyo
Copy link

Sekkyo commented Jan 10, 2022

It will not. It just copies/moves the file(s) in its current storage class to the new storage class. Any upload still goes to Standard at first like any S3 upload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made. guidance Question that needs advice or information. s3 service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

7 participants