All Products
Search
Document Center

Object Storage Service:put-bucket-resource-group

Last Updated:Mar 20, 2026

Assigns a bucket to a resource group by setting the resource group ID on the bucket.

Permissions

By default, an Alibaba Cloud account has full permissions. RAM users and RAM roles have no permissions by default. Grant the required permissions through RAM Policy or Bucket Policy before running this command.

APIActionDescription
PutBucketResourceGrouposs:PutBucketResourceGroupConfigures a resource group for a bucket.

Command syntax

ossutil api put-bucket-resource-group --bucket value [flags]
ParameterTypeDescription
--bucketstringThe bucket for which you want to modify the resource group ID.
--resource-group-configurationstringThe container that stores the resource group ID.
For supported global flags, see Command-line options.

--resource-group-configuration

Pass the resource group configuration as inline JSON, or as a file using the file:// prefix. Both XML and JSON formats are supported.

Inline JSON

Pass the configuration directly in the command without creating a file:

ossutil api put-bucket-resource-group --bucket <bucket-name> --resource-group-configuration "{\"ResourceGroupId\":\"<resource-group-id>\"}"

File-based configuration

For repeated use or version control, store the configuration in a file and reference it with the file:// prefix.

XML format:

<BucketResourceGroupConfiguration>
  <ResourceGroupId>string</ResourceGroupId>
</BucketResourceGroupConfiguration>

JSON format:

{
  "ResourceGroupId": "string"
}
This command corresponds to the PutBucketResourceGroup API operation. For full parameter details, see the API reference.

Examples

The following examples assign examplebucket to resource group rg-123.

Option 1: Inline JSON

ossutil api put-bucket-resource-group --bucket examplebucket --resource-group-configuration "{\"ResourceGroupId\":\"rg-123\"}"

Option 2: XML file

Create resource-group-configuration.xml:

<?xml version="1.0" encoding="UTF-8"?>
<BucketResourceGroupConfiguration>
  <ResourceGroupId>rg-123</ResourceGroupId>
</BucketResourceGroupConfiguration>

Run the command:

ossutil api put-bucket-resource-group --bucket examplebucket --resource-group-configuration file://resource-group-configuration.xml

Option 3: JSON file

Create resource-group-configuration.json:

{
  "ResourceGroupId": "rg-123"
}

Run the command:

ossutil api put-bucket-resource-group --bucket examplebucket --resource-group-configuration file://resource-group-configuration.json

What's next

  • To verify the change, run get-bucket-resource-group to retrieve the current resource group ID of the bucket.