33

By default storage in a bucket is STANDARD. And while pushing each object we can change the storage.

But is there a way to change default storage at Bucket level ( probably through AWS Console) ?

3 Answers 3

29

It's technically true that you cannot set the storage class on a per-bucket basis. However, you can specify a lifecycle policy on your bucket to automatically transition new objects to a storage class, as it says here.

The Standard - IA storage class is set at the object level and can exist in the same bucket as Standard, allowing you to use lifecycle policies to automatically transition objects between storage classes without any application changes.

To do this, go to the Management tab for a your bucket and click 'Add lifecycle rule' Add lifecycle rule

Give it a name and click next. For 'Configure transition', select current version. Click Add transition, choose "Transition to Standard-IA after" and choose 30, because 30 is the minimum. Finish your rule and you are all set.

enter image description here

4
  • 2
    does this transition incur (extra) costs? (i.e. as if requests was made on these objects)
    – pkaramol
    Oct 12, 2020 at 15:55
  • 1
    It does, and it can sneak up on you really quick. Ranges from $0.01 to $0.05 per 1000 transition requests.
    – Jordan
    May 12, 2021 at 20:25
  • 2
    It's better to set the policy in your PUT request rather than using a lifecycle policy due to the request costs.
    – rjh
    Nov 29, 2022 at 10:18
  • 1
    Yes, the costs of these request often are more than the hosting cost saving (!!) - best to do this during upload.
    – Hackeron
    Dec 28, 2022 at 17:09
11

The storage class cannot be set on a per-bucket basis. It must be specified with each upload operation in your client.

2
  • 3
    It is possible to pass extra header in object upload request (PUT Object, POST Object, and Initiate Multipart Upload): x-amz-storage-class: STANDARD_IA More info: docs.aws.amazon.com/AmazonS3/latest/dev/…
    – myroslav
    Jun 1, 2018 at 8:25
  • 1
    Has this situation changed at all in the past decade? - seems like setting a Storage Class for a bucket would be such an obvious thing...
    – Hackeron
    Dec 28, 2022 at 17:10
10

It is possible to specify storage class in upload request (PUT Object, POST Object, and Initiate Multipart Upload) via x-amz-storage-class header.

Additionally, if you want to enforce some storage classes in a bucket, you can do this via Bucket Policy (with s3:x-amz-storage-class condition key). This way any attempt to upload object with prohibited classes would fail.

Thus, you should do:

  1. Specify allowed storage class in Upload Operation (see details about x-amz-storage-class header).
  2. (optionally) Set s3:x-amz-storage-class key condition-based Bucket Policy (see example).
1
  • I found this a great addition to a program that was able to upload to AWS but was hiding the Deep Glacier option (likely, for paid version). I have specified this and it started to go to GDA Storage class right away.
    – onkami
    Nov 26, 2019 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.