All Products
Search
Document Center

Object Storage Service:PutBucketResourceGroup

Last Updated:Apr 02, 2025

You can use resource groups to manage resources. You can group the buckets to which you want to grant the same permissions to the same resource group and then grant permissions to the resource group. This improves the efficiency of authorization. This topic describes how to call the PutBucketResourceGroup operation to configure a resource group to which a bucket belongs.

Permissions

By default, an Alibaba Cloud account has full permissions on resources in the account. In contrast, RAM users and RAM roles associated with an Alibaba Cloud account initially have no permissions. To manage resources by using a RAM user or role, you must grant the required permissions via RAM policies or Bucket policies.

API

Action

Description

PutBucketResourceGroup

oss:PutBucketResourceGroup

Configures a resource group for a bucket. You must have the required permission for this operation on both the source resource group and the target resource group.

Request syntax

PUT /?resourceGroup
Date: GMT Date
Content-Length: ContentLength
Content-Type: application/xml
Host: BucketName.oss.aliyuncs.com
Authorization: SignatureValue 
<?xml version="1.0" encoding="UTF-8"?>
<BucketResourceGroupConfiguration>
  <ResourceGroupId>rg-aekz****</ResourceGroupId>
</BucketResourceGroupConfiguration>

Request headers

The request headers in a PutBucketResourceGroup request are only common request headers. For more information, see Common request headers.

Request elements

Element

Type

Required

Example

Description

BucketResourceGroupConfiguration

Container

Yes

N/A

The container that stores the ID of the resource group.

Child nodes: ResourceGroupId

ResourceGroupId

String

Yes

rg-aekz****

The ID of the resource group to which the bucket belongs.

If this element is not specified, the bucket is moved to the default resource group.

Parent nodes: BucketResourceGroupConfiguration

Response headers

The response to a PutBucketResourceGroup request contains only common response headers. For more information, see Common response headers.

Examples

Sample request

PUT /?resourceGroup
Content-Length: 0
Host: oss-example.oss-cn-hangzhou.aliyuncs.com
Date: Sat, 8 May 2021 01:33:47 GMT
Authorization: OSS qn6q**************:77Dv****************
<?xml version="1.0" encoding="UTF-8"?>
<BucketResourceGroupConfiguration>
  <ResourceGroupId>rg-aekz****</ResourceGroupId>
</BucketResourceGroupConfiguration>

Sample success response

HTTP/1.1 200 OK
x-oss-request-id: 5D3663FBB007B79097FC****
Date: Sat, 8 May 2021 01:33:47 GMT
Content-Length: 0
Connection: keep-alive
Server: AliyunOSS

OSS SDKs

You can use OSS SDKs for the following programming languages to call PutBucketResourceGroup:

ossutil

For information about the ossutil command that corresponds to the PutBucketResourceGroup operation, see put-bucket-resource-group.

Error codes

Error code

HTTP status code

Description

AccessDenied

403

Possible causes:

  • The information for user authentication is not imported when you initiate the request.

  • You do not have the permissions to perform the operation.

ResourceGroupIdPreCheckError

400

The specified ID of the resource group is invalid or does not exist. The ID of the resource group fails the precheck.