All Products
Search
Document Center

Object Storage Service:PutBucketResourceGroup

Last Updated:May 06, 2024

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.

Usage notes

By default, an Alibaba Cloud account has the permission to configure a resource group to which a bucket belongs. To configure a resource group to which a bucket belongs by using a RAM user or Security Token Service (STS), you must have the oss:PutBucketResourceGroup permission. For more information, see Attach a custom policy to a RAM user.

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

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.