All Products
Search
Document Center

Object Storage Service:resource-group, resource-group

Last Updated:Aug 13, 2024

You can run the resource-group command to configure a resource group for a bucket and query the resource groups of a bucket.

Usage notes

  • To configure a resource group for a bucket, you must have the oss:PutBucketResourceGroup permission. To query the resource groups of a bucket, you must have the oss:GetBucketResourceGroup permission. For more information, see Attach a custom policy to a RAM user.

  • For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you must specify a binary name that corresponds to the operating system. For more information, see ossutil command reference.

  • Only ossutil 1.7.16 and later support the resource-group command.

Configure a resource group for a bucket

  • Command syntax

    ossutil resource-group --method put oss://bucketname/ local_xml_file

    The following table describes the preceding parameters.

    Parameter

    Description

    bucketname

    The name of the bucket for which you want to configure a resource group.

    local_xml_file

    The name of the local file that is used to add resource group configurations. Example: config.xml.

  • Examples

    1. Add resource group configurations to a local XML file.

      <?xml version="1.0" encoding="UTF-8"?>
      <BucketResourceGroupConfiguration>
        <ResourceGroupId>rg-aekz****</ResourceGroupId>
      </BucketResourceGroupConfiguration>
    2. Specify a resource group for the examplebucket bucket by using the local XML file.

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

      Sample output:

      0.299514(s) elapsed

Query the resource groups of a bucket

  • Command syntax

    ossutil resource-group --method get oss://bucketname/ local_xml_file

    The following table describes the preceding parameters.

    Parameter

    Description

    bucketname

    The name of the bucket whose resource groups you want to query.

    local_xml_file

    The name of the local file that is used to store resource group configurations of the bucket. Example: local.xml.

  • Examples

    • Query and display the resource groups of a bucket named examplebucket:

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

      Sample output:

      <?xml version="1.0" encoding="UTF-8"?>
      <BucketResourceGroupConfiguration>
        <ResourceGroupId>rg-aekz****</ResourceGroupId>
      </BucketResourceGroupConfiguration>
      
      
      
      0.154689(s) elapsed
    • Query the resource groups of a bucket named examplebucket and store the resource group configurations as a local file:

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

      Sample output:

      • The following result is displayed:

        0.214483(s) elapsed
      • The local file contains the following content:

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