最近更新时间:2023.03.24 11:25:42
首次发布时间:2022.11.03 08:35:40
本文介绍VPC常用的自定义策略示例,主账号ID以210005****为例。
为子用户授权所有VPC中子网资源的管理权限时,由于子网中可能涉及云服务器、路由条目、辅助网卡等关联资源,所以除了授权子网的全部操作权限,还需要授权私有网络其他资源(如辅助网卡、路由表、路由条目等)和云服务器资源的查看权限。
按照以下配置授权成功后,子用户可以创建、删除子网,查看子网以及子网中关联的云服务器、路由条目、辅助网卡等资源信息。
{ "Statement": [ { "Effect": "Allow", "Action": [ "vpc:*Subnet*", "vpc:Describe*" ], "Resource": [ "trn:vpc:*:210005****:*/*" ] }, { "Effect": "Allow", "Action": [ "ecs:Describe*" ], "Resource": [ "*" ] } ] }
拒绝策略需要配合其他策略一起使用才能生效。用户被授权的策略中同时包含Allow和Deny配置时,Deny配置优先。
如果您希望子用户可以进行除删除VPC实例和子网资源外的所有操作时,可以为子用户授权系统预设策略VPCFullAccess和以下自定义策略:
{ "Statement": [ { "Effect": "Deny", "Action": [ "vpc:Delete*" ], "Resource": [ "trn:vpc:*:210005****:vpc/*", "trn:vpc:*:210005****:subnet/*" ] } ] }
以下配置以仅允许子用户修改指定路由表vtb-2fdzao4h726f45******中的路由条目为例。
{ "Statement": [ { "Effect": "Allow", "Action": [ "vpc:DescribeRouteTable*", "vpc:*RouteEntry*" ], "Resource": [ "trn:vpc:*:210005****:routetable/vtb-2fdzao4h726f45******", "trn:vpc:*:210005****:routeentry/*" ] }, { "Effect": "Allow", "Action": [ "vpc:Describe*" ], "Resource": [ "trn:vpc:*:210005****:eni/*", "trn:vpc:*:210005****:havip/*" ] }, { "Effect": "Allow", "Action": [ "ecs:Describe*" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "nat:Describe*" ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "vpn:Describe*" ], "Resource": [ "*" ] } ] }
参考以下配置为子用户授权VPC标签功能的使用权限。
{ "Statement":[ { "Effect":"Allow", "Action":[ "vpc:TagResources", "vpc:UntagResources", "vpc:ListTagsForResources" ], "Resource":[ "*" ] } ] }