Setting a quota on a bucket in IBM Cloud® Object Storage
Set a hard quota on an IBM Cloud® Object Storage bucket by using the console or API to cap storage in bytes and block new objects when the limit is reached.
There are two types of usage quota: a "hard" quota described above, and a "soft" quota that alerts a user that usage has crossed a threshold, but does not prevent any further object writes. To configure a soft quota, make use of Configure Metrics for IBM Cloud® Object Storage to set usage alerts.
Using the console
You can use the console to add a hard quota to a bucket during creation, or an existing bucket.
Creating a new bucket with a quota
- After navigating to your object storage instance, click on Create bucket.
- Under Advanced configurations, look for Quota enforcement and toggle the selector to Enabled.
- Now raise or lower the value and choose the appropriate storage unit. Then, click Save.
- Continue configuring any other rules, setting, or policies on the new bucket.
Adding a quota to an existing bucket
First, make sure that you have a bucket. If not, follow the getting started tutorial to become familiar with the console.
- Navigate to a bucket, so that you are looking at a list of objects. Select Configuration from the navigational menu.
- Under Advanced configurations, look for Quota enforcement and toggle the selector to Enabled.
- Now raise or lower the value and choose the appropriate storage unit. Then, click Save.
Disabling or editing a quota
- Navigate to the bucket where you want to change the quota, so that you are looking at a list of objects. Select Configuration from the navigational menu.
- Under Advanced configurations, look for Quota enforcement.
- If you want to disable the quota enforcement, toggle the selector to Disable. Alternatively, keep the quota enforcement enabled, but edit the values as needed.
- Click Save.
Using an API
Bucket quotas are managed with the COS Resource Configuration API.
To add a quota, you send a PATCH request to edit the bucket's metadata:
curl -X PATCH https://config.cloud-object-storage.cloud.ibm.com/v1/b/my-bucket \
-H 'authorization: bearer $IAM_TOKEN' \
-d '{"hard_quota": 10000000000}'
To disable the quota, set it to zero:
curl -X PATCH https://config.cloud-object-storage.cloud.ibm.com/v1/b/my-bucket \
-H 'authorization: bearer $IAM_TOKEN' \
-d '{"hard_quota": 0}'
To temporarily disable writing new data to the bucket, set the quota to a very small integer:
curl -X PATCH https://config.cloud-object-storage.cloud.ibm.com/v1/b/my-bucket \
-H 'authorization: bearer $IAM_TOKEN' \
-d '{"hard_quota": 1}'
To check the quota on a bucket, send a GET request to view the hard_quota field in the bucket's metadata:
curl https://config.cloud-object-storage.cloud.ibm.com/v1/b/my-bucket \
-H 'authorization: bearer $IAM_TOKEN'