全部產品
Search
文件中心

Tablestore:授權文法與元素

更新時間:Jun 19, 2026

Table Store通過 JSON 格式的授權策略實現資源的精細化存取控制。本文介紹授權策略的文法結構,以及 Action、Resource、Condition 元素的取值與配置方式,適用於 Instance Policy、RAM Policy、Control Policy 等權限原則的編寫。

授權文法

授權策略採用 JSON 格式描述,由版本號碼(Version)和一條或多條授權語句(Statement)組成。每條授權語句包含效果(Effect)、操作(Action)、資源(Resource)和條件(Condition)等基本元素。

文法結構

{
    "Version": "1",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": ["ots:操作名稱"],
            "Resource": ["acs:ots:地區:帳號ID:執行個體與資源路徑"],
            "Condition": {
                "條件操作類型": {
                    "條件關鍵字": ["條件值"]
                }
            }
        }
    ]
}

欄位說明

欄位

說明

是否必填

Version

授權策略的版本號碼,固定取值為1

Statement

授權語句的主體,支援配置一條或多條授權語句。

Effect

授權效果,取值為Allow(允許)或Deny(拒絕)。

Action

允許或拒絕的操作。更多資訊,請參見Action

Resource

被授權的資源。更多資訊,請參見Resource

Condition

授權生效的條件。更多資訊,請參見Condition

Action

Action 是對資源執行的操作,每個 Action 需添加ots:首碼,多個 Action 以半形逗號(,)分隔,支援使用星號(*)萬用字元(包括首碼匹配和尾碼匹配)。典型的 Action 定義如下:

單個 API

"Action": "ots:GetRow"

多個 API

"Action": [
    "ots:PutRow",
    "ots:GetRow"
]

所有隻讀 API

"Action": [
    "ots:BatchGet*",
    "ots:Describe*",
    "ots:Get*",
    "ots:List*",
    "ots:Consume*",
    "ots:Search",
    "ots:ComputeSplitPointsBySize"
]

所有讀寫 API

"Action": "ots:*"

所有 SQL 操作 API

"Action": "ots:SQL*"

Resource

資源由產品、地區、帳號 ID、執行個體名和表名等欄位組成,通過 Resource 指定使用者可訪問的資源範圍。每個欄位均支援星號(*)萬用字元(包括首碼匹配和尾碼匹配)。Resource 格式如下:

acs:ots:[region]:[user_id]:instance/[instance_name]/table/[table_name]

其中產品固定取值為 ots[region]為資源所在地區的 RegionID(例如 cn-hangzhou),[user_id]為阿里雲帳號 ID,[instance_name]為執行個體名稱,[table_name]為表名稱,請根據實際配置替換。

Tunnel 涉及的 Resource 定義只能到執行個體層級,即由產品、地區、帳號 ID 和執行個體名組成。Resource 格式如下:

acs:ots:[region]:[user_id]:instance/[instance_name]

注意事項

  • Table Store中執行個體名稱不區分大小寫,在 Resource 資源定義中的[instance_name]請用小寫表示。

  • Action 和 Resource 通過字串匹配進行驗證,並且萬用字元星號(*)區分首碼和尾碼匹配。例如 Resource 定義為acs:ots:*:*:instance/abc時,無法匹配 acs:ots:*:*:instance/abc/table/xyz

  • 登入Table Store控制台管理執行個體資源時,由於控制台需要擷取執行個體的列表,因此需要授予使用者acs:ots:[region]:[user_id]:instance/*資源的讀取許可權。

  • 對於大量操作 API(例如 BatchGetRow、BatchWriteRow),Table Store會對被訪問的每張表分別鑒權,只有所有表都通過鑒權才能執行操作,否則會返回許可權錯誤。

典型 Resource 定義

  • 所有地區的所有帳號的所有資源。

    "Resource": "acs:ots:*:*:*"
  • 華東 1(杭州)地區、帳號 123456 的所有執行個體及其下所有表。

    "Resource": "acs:ots:cn-hangzhou:123456:instance*"
  • 華東 1(杭州)地區、帳號 123456 中名稱為 abc 的執行個體及其下所有表。

    "Resource": [
        "acs:ots:cn-hangzhou:123456:instance/abc",
        "acs:ots:cn-hangzhou:123456:instance/abc/table*"
    ]
  • 所有以 abc 開頭的執行個體及其下所有表。

    "Resource": "acs:ots:*:*:instance/abc*"
  • 所有以 abc 開頭的執行個體下所有以 xyz 開頭的表(不包括執行個體資源,不匹配acs:ots:*:*:instance/abc*)。

    "Resource": "acs:ots:*:*:instance/abc*/table/xyz*"

API 類型與資源

目前Table Store的 API 主要分為執行個體管理類 API、表和資料讀寫類 API。不同類型 API 訪問的資源的配置資訊如下:

管理類API訪問的資源

管理類 API 主要為執行個體相關的操作,控制台和 OpenAPI 都會調用。以下訪問的資源省略了acs:ots:[region]:[user_id]:首碼,只描述執行個體部分。

API名稱

Action

訪問的資源

CreateInstance

ots:InsertInstance

instance/[instance_name]

UpdateInstance

ots:UpdateInstance

instance/[instance_name]

GetInstance

ots:GetInstance

instance/[instance_name]

DeleteInstance

ots:DeleteInstance

instance/[instance_name]

ListInstances

ots:ListInstance

instance/*

ChangeResourceGroup

ots:UpdateInstance

instance/[instance_name]

ListTagResources

ots:ListTagResourcesCustomTags

instance/*

TagResources

ots:TagResourcesCustomTags

instance/[instance_name]

UntagResources

ots:UntagResourcesCustomTags

instance/[instance_name]

UpdateInstancePolicy

ots:UpdateInstancePolicy

instance/[instance_name]

DeleteInstancePolicy

ots:DeleteInstancePolicy

instance/[instance_name]

CheckInstancePolicy

ots:CheckInstancePolicy

instance/[instance_name]

UpdateInstanceElasticVCUUpperLimit

ots:UpdateInstanceElasticVCUUpperLimit

instance/[instance_name]

資料類API訪問的資源

資料類 API 主要為表和行相關的操作,控制台和 SDK 都會調用。該類 API 的 Action 和 Resource 定義會影響使用者對控制台的使用。以下訪問的資源省略了acs:ots:[region]:[user_id]:首碼,只描述執行個體和表部分。

API名稱

Action

訪問的資源

ListTable

ots:ListTable

instance/[instance_name]/table*

CreateTable

ots:CreateTable

instance/[instance_name]/table/[table_name]

UpdateTable

ots:UpdateTable

instance/[instance_name]/table/[table_name]

DescribeTable

ots:DescribeTable

instance/[instance_name]/table/[table_name]

DeleteTable

ots:DeleteTable

instance/[instance_name]/table/[table_name]

CreateGlobalTable

ots:CreateGlobalTableots:UpdateTableots:CreateTunnelots:DescribeTunnelots:ListTunnelots:TunnelReadRecordsots:BatchWriteRow

instance/[instance_name]/table/[table_name]

DescribeGlobalTable

ots:DescribeGlobalTable

instance/[instance_name]/table/[table_name]

UpdateGlobalTable

ots:UpdateGlobalTableots:UpdateTableots:CreateTunnelots:DescribeTunnelots:ListTunnelots:TunnelReadRecordsots:BatchWriteRow

instance/[instance_name]/table/[table_name]

BindGlobalTable

ots:BindGlobalTableots:UpdateTableots:CreateTunnelots:DescribeTunnelots:ListTunnelots:TunnelReadRecordsots:BatchWriteRow

instance/[instance_name]/table/[table_name]

UnbindGlobalTable

ots:UnbindGlobalTableots:UpdateTableots:DeleteTunnel

instance/[instance_name]/table/[table_name]

AddDefinedColumn

ots:AddDefinedColumn

instance/[instance_name]/table/[table_name]

DeleteDefinedColumn

ots:DeleteDefinedColumn

instance/[instance_name]/table/[table_name]

GetRow

ots:GetRow

instance/[instance_name]/table/[table_name]

PutRow

ots:PutRow

instance/[instance_name]/table/[table_name]

UpdateRow

ots:UpdateRow

instance/[instance_name]/table/[table_name]

DeleteRow

ots:DeleteRow

instance/[instance_name]/table/[table_name]

GetRange

ots:GetRange

instance/[instance_name]/table/[table_name]

BatchGetRow

ots:BatchGetRow

instance/[instance_name]/table/[table_name]

BatchWriteRow

ots:BatchWriteRow

instance/[instance_name]/table/[table_name]

ComputeSplitPointsBySize

ots:ComputeSplitPointsBySize

instance/[instance_name]/table/[table_name]

StartLocalTransaction

ots:StartLocalTransaction

instance/[instance_name]/table/[table_name]

CommitTransaction

ots:CommitTransaction

instance/[instance_name]/table/[table_name]

AbortTransaction

ots:AbortTransaction

instance/[instance_name]/table/[table_name]

CreateIndex

ots:CreateIndex

instance/[instance_name]/table/[table_name]

DropIndex

ots:DropIndex

instance/[instance_name]/table/[table_name]

CreateSearchIndex

ots:CreateSearchIndex

instance/[instance_name]/table/[table_name]

UpdateSearchIndex

ots:UpdateSearchIndex

instance/[instance_name]/table/[table_name]

DeleteSearchIndex

ots:DeleteSearchIndex

instance/[instance_name]/table/[table_name]

ListSearchIndex

ots:ListSearchIndex

instance/[instance_name]/table/[table_name]

DescribeSearchIndex

ots:DescribeSearchIndex

instance/[instance_name]/table/[table_name]

Search

ots:Search

instance/[instance_name]/table/[table_name]

ComputeSplits

ots:ComputeSplits

instance/[instance_name]/table/[table_name]

ParallelScan

ots:ParallelScan

instance/[instance_name]/table/[table_name]

CreateTunnel

ots:CreateTunnel

instance/[instance_name]/table/[table_name]

DeleteTunnel

ots:DeleteTunnel

instance/[instance_name]/table/[table_name]

ListTunnel

ots:ListTunnel

instance/[instance_name]/table/[table_name]

ConsumeTunnel

ots:ConsumeTunnel

instance/[instance_name]/table/[table_name]

DescribeTunnel

ots:DescribeTunnel

instance/[instance_name]/table/[table_name]

BulkImport

ots:BulkImport

instance/[instance_name]/table/[table_name]

BulkExport

ots:BulkExport

instance/[instance_name]/table/[table_name]

SQL_Select

ots:SQL_Select

instance/[instance_name]/table/[table_name]

SQL_Create

ots:SQL_Create

instance/[instance_name]/table/[table_name]

SQL_DropMapping

ots:SQL_DropMapping

instance/[instance_name]/table/[table_name]

Condition

Condition 用於指定授權生效的限制條件,由條件操作類型、條件關鍵字和條件值組成。

條件操作類型

條件操作類型用於指定條件關鍵字與條件值的比較方式,支援字串類型(String)、數字類型(Number)、日期類型(Date and time)、布爾類型(Boolean)、IP 位址類型(IP address)等。完整的條件操作類型及其運算子說明,請參見條件運算子

條件關鍵字

Table Store支援配置的自訂 Condition 和通用 Condition 說明請參見下表。

類型

條件關鍵字

說明

Table Store自訂Condition

ots:EncryptionRequired

適用於CreateTable、UpdateTable操作,是否只允許建立或更新加密表。

取實值型別為String,取值範圍為true、false。

配置樣本:"ots:EncryptionRequired": "true"

ots:IsFromTrustProxy

對來自可信代理(從控制台訪問時為可信代理)的訪問進行許可權配置,是否只允許可信代理的訪問。

取實值型別為String,取值範圍為true、false。

配置樣本:"ots:IsFromTrustProxy": "true"

ots:AllowInstanceInternetAccess

適用於CreateInstance、UpdateInstance操作,是否只允許建立不能從公網訪問的執行個體。

取實值型別為String,取值範圍為true、false。

配置樣本:"ots:AllowInstanceInternetAccess": "true"

ots:TLSVersion

設定允許的用戶端TLS版本,同時也限制了只能使用HTTPS協議進行訪問。

取實值型別為String,取值範圍為TLSv1、TLSv1.1、TLSv1.2、TLSv1.3。

單個條件中支援同時配置多個TLS版本。當配置多個TLS版本時,用戶端採用配置中的任意一種TLS版本訪問Table Store均可成功。

ots:AccessId

限制訪問來源的使用者AccessKey ID(AK)。

取實值型別為String。如果有多個AccessId,請按行輸入,一行輸入一個AccessId。

通用Condition

acs:SourceIp

限制訪問來源的IP地址或網段。

取實值型別為String,取值範圍為IPv4/IPv6的IP地址、CIDR網段。單個條件中支援同時配置多個IP地址或IP網段。

重要

配置Instance Policy時,如果配置了acs:SourceIp,必須同時配置acs:SourceVpc以明確請求的網路來源,否則配置無法提交。這是因為acs:SourceIp僅匹配請求的源IP地址,不區分該IP來自公網還是VPC內網,僅使用acs:SourceIp限制訪問可能存在越權風險。

acs:SourceVpc

限制訪問來源的VPC。

取實值型別為String,取值範圍為源端的VPC ID以及vpc-*。單個條件中支援配置多個VPC ID,請確保配置的VPC ID正確。

acs:SecureTransport

限制請求的協議類型,即是否通過安全傳輸(HTTPS)訪問。

取實值型別為Bool,取值範圍如下:

  • true:僅允許HTTPS請求訪問。

  • false:僅允許HTTP請求訪問。

如果未設定acs:SecureTransport,表示HTTP或HTTPS請求均可以訪問。

acs:CurrentTime

限制請求到達Table Store服務端的時間。

取實值型別為Date and time,格式為ISO8601,例如2016-01-01T00:00:00+08:00

acs:MFAPresent

限制是否通過MFA(多因素認證)訪問。

取實值型別為Bool,取值範圍為true、false。