Sets a resource policy on a table to control access from other accounts or roles.
Usage notes
-
A resource policy controls access to the table for other accounts or roles.
-
The
resourcePolicyparameter is a JSON string that conforms to Alibaba Cloud RAM policy syntax. -
A new policy overwrites the existing one. To delete a policy, call
DeleteTablePolicy.
Permissions
|
API |
Action |
Description |
|
PutTablePolicy |
oss:PutTablePolicy |
Sets the resource policy for a table. |
Request syntax
PUT /tables/{tableBucketARN}/{namespace}/{name}/policy HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue
{
"resourcePolicy": "string"
}
Request parameters
|
Parameter |
Type |
Required |
Example |
Description |
|
tableBucketARN |
String |
Yes |
acs:osstables:cn-hangzhou:1234567890:bucket/my-table-bucket |
The table bucket ARN, specified in the URI. Format: |
|
namespace |
String |
Yes |
my_namespace |
The namespace containing the table, specified in the URI. |
|
name |
String |
Yes |
my_table |
The table name, specified in the URI. |
|
resourcePolicy |
String |
Yes |
See the request example. |
JSON string in the request body that conforms to Alibaba Cloud RAM policy syntax. Defines allowed or denied actions, principals, and conditions. |
Examples
Request example
PUT /tables/acs%3Aosstables%3Acn-hangzhou%3A1234567890%3Abucket%2Fmy-table-bucket/my_namespace/my_table/policy HTTP/1.1
Content-type: application/json
Host: cn-hangzhou.oss-tables.aliyuncs.com
Date: Thu, 10 Apr 2025 08:00:00 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/osstables/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c****
{
"resourcePolicy": "{\"Version\":\"1\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"oss:GetTable\"],\"Principal\":[\"acs:ram::1234567890:root\"],\"Resource\":[\"acs:osstables:cn-hangzhou:*:bucket/my-table-bucket/table/*\"]}]}"
}
Response example
HTTP/1.1 200 OK
Server: AliyunOSS
x-oss-request-id: 5C06A3B67B8B5A3DA422****
x-oss-server-time: 3
SDKs
PutTablePolicy is available in the following SDKs:
ossutil CLI
The corresponding ossutil command is put-table-policy.
Error codes
|
Error code |
HTTP status code |
Description |
|
BadRequestException |
400 |
The request is invalid or malformed. |
|
ForbiddenException |
403 |
The caller lacks the required permissions. |
|
NotFoundException |
404 |
The requested resource does not exist. |