You can run the resource-group command to configure a resource group for a bucket and obtain the resource group of a bucket.
Usage notes
To configure a resource group for a bucket, you must have the
oss:PutBucketResourceGroup
permission. To query the resource group of a bucket, you must have theoss:GetBucketResourceGroup
permission. For more information, see Attach a custom policy to a RAM user.This topic provides sample command lines that are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. 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
./ossutil64 resource-group --method put oss://bucketname/ local_xml_file
The following table describes the parameters in the syntax.
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
Specify a resource group for a bucket in the local XML file.
<?xml version="1.0" encoding="UTF-8"?> <BucketResourceGroupConfiguration> <ResourceGroupId>rg-aekz****</ResourceGroupId> </BucketResourceGroupConfiguration>
Specify a resource group for the examplebucket bucket.
./ossutil64 resource-group --method put oss://examplebucket/ config.xml
Sample output:
0.299514(s) elapsed
Query the resource group of a bucket
Command syntax
./ossutil64 resource-group --method get oss://bucketname/ local_xml_file
The following table describes the parameters in the syntax.
Parameter
Description
bucketname
The name of the bucket whose resource group you want to query.
local_xml_file
The name of the local file used to store resource group information of the bucket. Example:
local.xml
.Examples
The following code provides an example on how to obtain and display the resource group of the bucket named examplebucket:
./ossutil resource-group --method get oss://examplebucket/
The following output is returned:
<?xml version="1.0" encoding="UTF-8"?> <BucketResourceGroupConfiguration> <ResourceGroupId>rg-aekz****</ResourceGroupId> </BucketResourceGroupConfiguration> 0.154689(s) elapsed
The following code provides an example on how to obtain the resource group of the bucket named examplebucket and store the resource group information as a local file:
./ossutil resource-group --method get oss://examplebucket/ local.xml
The following output is returned:
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>