创建当前账号自定义规则模板,并定义适用资源范围、触发方式、允许执行效果、参数和 Rego 策略;后续可基于模板创建规则。
下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。
参数 | 类型 | 是否必填 | 示例值 | 描述 |
|---|---|---|---|---|
Action | String | 是 | CreateRuleTemplate | 要执行的操作,取值:CreateRuleTemplate。 |
Version | String | 是 | 2025-01-01 | API的版本,取值:2025-01-01。 |
TemplateName | String | 是 | example-template | 规则模板名称 |
Description | String | 是 | example description | 描述 |
RiskLevel | String | 是 | Low | 风险等级,可选值:Low,Medium,High |
Scope | Object | 是 | {"ResourceTypes":["Volcengine::Ecs::Instance"]} | 资源评估范围 |
Triggers | Array of Object | 是 | [{"TriggerType":"ConfigurationItemChange"}] | 规则触发方式配置 |
Parameters | Array of Object | 是 | [{"Name":"example-name","Description":"example description","AllowedValues":"["cn-beijing","cn-shanghai"]","DefaultValue":"cn-beijing","ValueType":"string","IsCompulsory":"true"}] | 规则模板参数定义 |
PolicyRule | String | 是 | package volcengine.config compliant if { input.ConfigurationItem.Region == "cn-beijing" } | 规则模板的 Rego 策略内容 |
AllowedEffects | Array of String | 否 | ["Audit","Modify"] | 规则模板允许创建的规则执行效果,可选值:Audit,Modify;不传时默认 ["Audit"] |
下表仅列出本接口特有的返回参数。更多信息请参见返回结构。
参数 | 类型 | 示例值 | 描述 |
|---|---|---|---|
TemplateId | String | rt-123456 | 规则模板 ID |
POST /?Action=CreateRuleTemplate&Version=2025-01-01 HTTP/1.1 Host: config.volcengineapi.com Content-Type: application/json; charset=UTF-8 X-Date: 20260518T164649Z X-Content-Sha256: 287e874e******d653b44d21e Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20260518/cn-beijing/config/request, SignedHeaders=host;x-content-sha256;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f { "TemplateName": "example-template", "Description": "example description", "RiskLevel": "Low", "Scope": { "ResourceTypes": [ "Volcengine::Ecs::Instance" ] }, "Triggers": [ { "TriggerType": "ConfigurationItemChange", "MaximumExecutionFrequency": "TwentyFour_Hours" } ], "Parameters": [ { "Name": "example-name", "Description": "example description", "AllowedValues": "example", "DefaultValue": "example", "ValueType": "example", "IsCompulsory": false } ], "PolicyRule": "package rules\n\ndefault compliance_type = \"COMPLIANT\"" }
{ "ResponseMetadata": { "RequestId": "202605181646490000000000000000", "Action": "CreateRuleTemplate", "Version": "2025-01-01", "Service": "config", "Region": "cn-beijing" }, "Result": { "TemplateId": "rt-123456" } }
下表为您列举了该接口与业务逻辑相关的错误码。公共错误码请参见公共错误码文档。
状态码 | 错误码 | 说明 |
|---|---|---|
400 | InvalidParameter | |
500 | InternalError |