You need to enable JavaScript to run this app.
导航
资源(Resource)
最近更新时间:2024.09.12 16:27:33首次发布时间:2023.09.05 17:54:33

资源(Resource) 元素内包含着权限声明定义的资源范围,使用TRN 表达式定义。TRN(The Resource Name) 是火山引擎上资源的全局唯一标识,由服务、地域、账号、资源路径等信息组成,格式如下:

字段
说明示例值必填
trnTRN的固定前缀trn
${ServiceCode}云服务的英文代码,例如云服务器的ServiceCode为ecs,不同云产品的ServiceCode可从服务的API文档中查询。ecs

${RegionCode}

资源所属的地域,全局资源该字段值应为空。以下是不同地域的RegionCode

  • 华北2(北京):cn-beijing

  • 华东2(上海):cn-shanghai

  • 华南1(广州):cn-guangzhou

cn-beijing

${AccountId}资源所属的账号ID2000000001
${ResourcePath}资源路径,例如云服务器的资源路径为instance/${InstanceId}instance为云服务实例的固定资源类型名,${InstanceId}为云服务器实例的ID。不同资源类型的路径格式可参考文档末尾的表格。instance/i-abc123

示例1:AccountID为2000000001的账号在cn-beijing创建的实例id=i-100的云服务器,对应的资源TRN为trn:ecs:cn-beijing:2000000001:instance/i-100

示例2:AccountID为2000000001的账号创建的用户名为Bob的IAM用户,对应的资源TRN为trn:iam::2000000001:user/Bob (IAM为全局服务,不区分地域,因此这里的地域值为空)

Resource元素支持整体以通配符*表达,或在TRN从第2段至后续的每一段中使用通配符:

  • 通配符*:匹配0个、1个或多个字符。
  • 通配符?:匹配一个字符(不能为0个)。

以下是一条包含Resource的策略:

{
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecs:DeleteInstance"
      ],
      "Resource": [
        "trn:ecs:cn-beijing:2000000001:instance/i-100",
        "trn:ecs:cn-beijing:2000000001:instance/i-200"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "iam:GetUser"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}

解读: 该条策略定义了允许删除实例ID为i-100和i-200的云服务器实例以及允许查询全部IAM用户的权限。

支持的云服务资源类型

您可参考具体的云服务产品文档了解支持的资源类型,以下给出了一些常用服务的资源TRN格式:

产品
ServiceCode
资源类型
ResourceType
trn格式
云服务器ecs实例instancetrn:ecs:{region}:{account}:instance/{instanceid}
密钥对keypairtrn:ecs:{region}:{account}:keypair/{keypairname}
镜像imagetrn:ecs:{region}:{account}:image/{imageid}
弹性块存储storage_ebsvolumevolumetrn:storage_ebs:{region}:{account}:volume/{volumeid}
云数据库 RDS MySQLrds_mysql实例instancetrn:rds_mysql:{region}:{account}:instance/{instanceid}
缓存数据库Redis版Redis实例instancetrn:Redis:{region}:{account}:instance/{instanceid}
内容分发网络CDN域名Domaintrn:CDN:{region}:{account}:Domain/{domain}
应用型负载均衡alb实例loadbalancertrn:alb:{region}:{account}:loadbalancer/{id}
监听器listenertrn:alb:{region}:{account}:listener/{id}
服务器组servergrouptrn:alb:{region}:{account}:servergroup/{id}
个性化配置customizedcfgtrn:alb:{region}:{account}:customizedcfg/{id}
证书certificatetrn:alb:{region}:{account}:certificate/{id}
访问控制acltrn:alb:{region}:{account}:acl/{id}
公网IPvpc实例eiptrn:vpc:{region}:{account}:eip/{eipid}
共享带宽包vpc实例bandwidthpackagetrn:vpc:{region}:{account}:bandwidthpackage/{bandwidthpackageid}
私有网络vpc私有网络实例vpctrn:vpc:{region}:{account}:vpc/{vpcid}
子网subnettrn:vpc:{region}:{account}:subnet/{subnetid}
网卡enitrn:vpc:{region}:{account}:eni/{eniid}
安全组securitygrouptrn:vpc:{region}:{account}:securitygroup/{securitygroupid}
路由表routetabletrn:vpc:{region}:{account}:routetable/{routetableid}
网络ACLnetworkacltrn:vpc:{region}:{account}:networkacl/{networkaclid}
NAT网关natgateway实例ngwtrn:natgateway:{region}:{account}:ngw/{ngwid}
VPN连接vpnVPN网关vpngatewaytrn:vpn:{region}:{account}:vpngateway/{vpngatewayid}
用户网关customergatewaytrn:vpn:{region}:{account}:customergateway/{customergatewayid}
IPSec连接vpnconnectiontrn:vpn:{region}:{account}:vpnconnection/{vpnconnectionid}
VPN网关路由vpngatewayroutetrn:vpn:{region}:{account}:vpngatewayroute/{vpngatewayrouteid}
专线连接directconnect物理专线connectiontrn:directconnect:{region}:{account}:connection/{id}
专线网关directconnectgatewaytrn:directconnect:{region}:{account}:directconnectgateway/{id}
中转路由器transitrouterTR实例transitroutertrn:transitrouter:{region}:{account}:transitrouter/{transitrouterid}
TR连接transitrouterattachmenttrn:transitrouter:{region}:{account}:transitrouterattachment/{transitrouterattachmentid}
TR路由表transitrouterroutetabletrn:transitrouter:{region}:{account}:transitrouterroutetable/{transitrouterroutetableid}
TR路由条目transitrouterrouteentrytrn:transitrouter:{region}:{account}:transitrouterrouteentry/{transitrouterrouteentryid}
TR带宽包transitrouterbandwidthpackagetrn:transitrouter::{account}:transitrouterbandwidthpackage/{transitrouterbandwidthpackageid}
负载均衡clb负载均衡实例clbtrn:clb:{region}:{account}:clb/{clbid}
访问控制策略组acltrn:clb:{region}:{account}:acl/{aclid}
证书certificatetrn:clb:{region}:{account}:certificate/{certificateid}
独占集群ectrn:clb:{region}:{account}:ec/{{ecid}
容器服务vke集群clustertrn:vke:{region}:{account}:cluster/{id}
对象存储tosbuckettrn:tos:{region}:{account}:{bucket}
对象objecttrn:tos:{region}:{account}:{bucket}/{object}
访问控制iam用户usertrn:iam::{account}:user/{UserName}
用户组grouptrn:iam::{account}:group/{GroupName}
角色roletrn:iam::{account}:role/{RoleName}
策略policytrn:iam::{account}:policy/{PolicyName}
项目projecttrn:iam::{account}:project/{ProjectName}