调用CreateControlPolicy创建自定义管控策略。
接口说明
本文将提供一个示例,创建一个名为ExampleControlPolicy的管控策略,禁止修改 ResourceDirectoryAccountAccessRole 角色及其权限。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
resourcemanager:CreateControlPolicy |
create |
*ControlPolicy
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| PolicyName |
string |
是 |
管控策略名称。 长度为 1~128 个字符,必须以英文字母开头,可以包含英文字母、数字和短划线(-)。 |
ExampleControlPolicy |
| Description |
string |
否 |
管控策略描述。 长度为 1~1024 个字符,必须以英文字母开头,可以包含英文字母、数字、下划线(_)和短划线(-)。 |
ExampleControlPolicy |
| EffectScope |
string |
是 |
管控策略的生效范围。 取值:RAM,表示该管控策略仅针对 RAM 用户或 RAM 角色生效。 |
RAM |
| PolicyDocument |
string |
是 |
管控策略内容。 最大长度为 4096 个字符。 管控策略语言,请参见管控策略语言。 管控策略示例,请参见自定义管控策略示例。 |
{"Version":"1","Statement":[{"Effect":"Deny","Action":["ram:UpdateRole","ram:DeleteRole","ram:AttachPolicyToRole","ram:DetachPolicyFromRole"],"Resource":"acs:ram:*:*:role/ResourceDirectoryAccountAccessRole"}]} |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
返回结果。 |
||
| ControlPolicy |
object |
管控策略详情。 |
|
| UpdateDate |
string |
管控策略更新时间,采用 RFC 3339 UTC 时间格式,以 Z 表示 UTC。 |
2021-03-18T09:24:19Z |
| Description |
string |
管控策略描述。 |
ExampleControlPolicy |
| EffectScope |
string |
管控策略生效范围。 取值:RAM,表示该管控策略仅针对 RAM 用户或 RAM 角色生效。 |
RAM |
| AttachmentCount |
string |
管控策略被引用的次数。 |
0 |
| PolicyName |
string |
管控策略名称。 |
ExampleControlPolicy |
| PolicyId |
string |
管控策略 ID。 |
cp-jExXAqIYkwHN**** |
| CreateDate |
string |
管控策略创建时间,采用 RFC 3339 UTC 时间格式,以 Z 表示 UTC。 |
2021-03-18T09:24:19Z |
| PolicyType |
string |
管控策略类型。取值:
|
Custom |
| RequestId |
string |
请求 ID。 |
776B05B3-A0B0-464B-A191-F4E1119A94B2 |
示例
正常返回示例
JSON格式
{
"ControlPolicy": {
"UpdateDate": "2021-03-18T09:24:19Z",
"Description": "ExampleControlPolicy",
"EffectScope": "RAM",
"AttachmentCount": "0",
"PolicyName": "ExampleControlPolicy",
"PolicyId": "cp-jExXAqIYkwHN****",
"CreateDate": "2021-03-18T09:24:19Z",
"PolicyType": "Custom"
},
"RequestId": "776B05B3-A0B0-464B-A191-F4E1119A94B2"
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 409 | InvalidParameter.PolicyDocument.Length | The maximum length of the policy document is exceeded. It must not exceed 4096 characters. |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。