kevin peter
kevin peter

Reputation: 571

Change S3 Bucket Storage class to S3 Infrequent Access

I want to change the S3 bucket to have default storage class of Infrequent Access.

So if I upload file to the bucket, it should directly go to Infrequent Access storage.

I don't want to use the Lifecycle

Upvotes: 17

Views: 12109

Answers (3)

prashantsahni
prashantsahni

Reputation: 2195

You can now create a bucket policy with a specific storage class now

https://docs.aws.amazon.com/AmazonS3/latest/userguide/security_iam_service-with-iam.html#example-storage-class-condition-key

This way any attempt to upload object with prohibited classes would fail.

{
                 "Version": "2012-10-17",
                 "Statement": [
                   {
                     "Sid": "statement1",
                     "Effect": "Allow",
                     "Principal": {
                       "AWS": "arn:aws:iam::123456789012:user/Dave"
                     },
                     "Action": "s3:PutObject",
                     "Resource": "arn:aws:s3:::DOC-EXAMPLE-BUCKET1/*",
                     "Condition": {
                       "StringEquals": {
                         "s3:x-amz-storage-class": [
                           "STANDARD_IA"
                         ]
                       }
                     }
                   }
                 ]
            }

Upvotes: 0

kevin peter
kevin peter

Reputation: 571

I found the answer myself.

Using cli-

aws s3 cp glacier.png s3://my-lambada-example-thumbnails/ --storage-class STANDARD_IA

So by using --storage-class we could specify the storage class.

Also when uploading from AWS console we get to specify the storage class.

Those who are using AWS File Gateway and want to change Storage class from S3 standard to IA can change as shown below.

enter image description here

Upvotes: 14

John Rotenstein
John Rotenstein

Reputation: 269540

There is no concept of a default storage class for an Amazon S3 bucket.

The storage class is specific to the object and can be specified when the object is created in the bucket.

You will need to change your upload process to specify the storage class at the time of object creation.

You can use the lifecycle rules to later change storage classes based upon the age of the object, which is as close as you'll get to a "default storage class".

Upvotes: 19

Related Questions