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 · 4 comments
Closed

Recursively change storage class on bucket #2056

kaihendry opened this issue Jul 10, 2016 · 4 comments

Comments

@kaihendry
Copy link

@kaihendry kaihendry commented Jul 10, 2016

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
Copy link
Member

@kyleknap kyleknap commented Jul 12, 2016

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

@kaihendry kaihendry commented Jul 13, 2016

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

@m4h
Copy link

@m4h 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

@joesenova joesenova commented Apr 1, 2020

WIll this change of storage class charge for data transfer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants