All Products
Search
Document Center

Object Storage Service:resource-group, resource-group

Last Updated:Mar 20, 2026

Use the resource-group command to assign a resource group to a bucket or retrieve the resource group currently assigned to a bucket.

Prerequisites

Before you begin, make sure you have:

  • ossutil 1.7.16 or later. The resource-group command is not available in earlier versions.

  • The oss:PutBucketResourceGroup permission to assign a resource group to a bucket

  • The oss:GetBucketResourceGroup permission to retrieve the resource group of a bucket

For ossutil 1.6.16 and later, use ossutil directly as the binary name. For earlier versions, specify the OS-specific binary name. See ossutil command reference.

To grant these permissions to a RAM user, see Attach a custom policy to a RAM user.

Assign a resource group to a bucket

Syntax

ossutil resource-group --method put oss://<bucketname>/ <local_xml_file>
ParameterDescription
<bucketname>The name of the bucket to assign to a resource group.
<local_xml_file>The path to a local XML file that specifies the resource group ID. For example, config.xml.

XML file format

<?xml version="1.0" encoding="UTF-8"?>
<BucketResourceGroupConfiguration>
  <ResourceGroupId>rg-aekz****</ResourceGroupId>
</BucketResourceGroupConfiguration>
FieldDescription
ResourceGroupIdThe ID of the resource group to assign to the bucket.

Example

  1. Create a local XML file named config.xml with the resource group ID:

       <?xml version="1.0" encoding="UTF-8"?>
       <BucketResourceGroupConfiguration>
         <ResourceGroupId>rg-aekz****</ResourceGroupId>
       </BucketResourceGroupConfiguration>
  2. Run the following command to assign the resource group to examplebucket:

       ossutil resource-group --method put oss://examplebucket/ config.xml

    Expected output:

       0.299514(s) elapsed

Query the resource group of a bucket

Syntax

ossutil resource-group --method get oss://<bucketname>/ [local_xml_file]
ParameterDescription
<bucketname>The name of the bucket whose resource group you want to retrieve.
[local_xml_file](Optional) The path to a local file where the returned configuration is saved. For example, local.xml. If omitted, the result is printed to the terminal.

Output fields

FieldDescription
ResourceGroupIdThe ID of the resource group currently assigned to the bucket.

Examples

  • Retrieve and print the resource group of examplebucket:

      ossutil resource-group --method get oss://examplebucket/

    Expected output:

      <?xml version="1.0" encoding="UTF-8"?>
      <BucketResourceGroupConfiguration>
        <ResourceGroupId>rg-aekz****</ResourceGroupId>
      </BucketResourceGroupConfiguration>
    
      0.154689(s) elapsed
  • Retrieve the resource group of examplebucket and save it to local.xml:

      ossutil resource-group --method get oss://examplebucket/ local.xml

    Expected terminal output:

      0.214483(s) elapsed

    The saved file contains:

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