镜像服务 IMS-IMS自定义策略:策略样例

时间:2024-11-15 14:52:24

策略样例

  • 示例1:授权用户制作镜像
    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "ims:serverImages:create"
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "KMS:*:*"
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "ecs:cloudServers:get",
                    "ecs:servers:get",
                    "ecs:serverVolumes:use",
                    "ecs:cloudServers:list",
                    "ecs:serverVolumeAttachments:list",
                    "ecs:servers:list"
    
                ]
            },
            {
                "Effect": "Allow",
                "Action": [
                    "bms:servers:list",
                    "bms:servers:get",
                    "bms:serverFlavors:get"
                ]
            },
           {
                "Effect": "Allow",
                "Action": [
                    "evs:volumes:*"
                ]
            }
        ]
    }
    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "OBS:*:*"
                ]
            }
        ]
    }

    制作镜像对应的授权项为:ims:serverImages:create,其他授权项均为制作镜像所依赖的授权项。

  • 示例2:拒绝用户删除镜像

    拒绝策略需要同时配合其他策略使用,否则没有实际作用。用户被授予的策略中,一个授权项的作用如果同时存在Allow和Deny,则遵循Deny优先原则

    如果您给用户授予IMS FullAccess的系统策略,但不希望用户拥有IMS FullAccess中定义的删除镜像权限,您可以创建一条拒绝删除镜像的自定义策略,然后同时将IMS FullAccess和拒绝策略授予用户,根据Deny优先原则,则用户可以对IMS执行除了删除镜像外的所有操作。拒绝策略示例如下:

    {
        "Version": "1.1",
        "Statement": [
            {
                "Effect": "Deny",
                "Action": [
                    "ims:images:delete"
                ]
            }
        ]
    }
support.huaweicloud.com/usermanual-ims/ims_01_0415.html