Cloud Config allows you to write compliance package templates in configuration files. You can define, import, and export a compliance package template that contains the managed rules supported by Cloud Config or condition rules that you create based on your business requirements. This provides you with a powerful tool to manage compliance for your business. This topic describes the structure and parameters of a compliance package template to help you efficiently define sets of compliance rules based on your business requirements.
Template structure
A compliance package template is exported in a JSON file. The file name is the name of the compliance package and the file name extension is .json
. You can import a compliance package template in a .txt
or .json
file. The file size cannot exceed 1 MB. The file content consists of two parts: compliancePackTemplate
(optional) and configRuleTemplates
(required).
compliancePackTemplate
compliancePackTemplate
contains the name, description, and risk level of the compliance package. Syntax in the JSON format:
{
"riskLevel": 1,
"compliancePackName": "The name of the compliance package",
"description": "The description of the compliance package"
}
Parameter | Required | Description |
compliancePackName | No | The name of the compliance package. We recommend that you specify a name based on the compliance scenario. Example: BestPracticesForOSS. The name of a compliance package is determined based on the following rules:
|
riskLevel | No | The risk level of the compliance package. This parameter is used to distinguish the importance of different compliance packages. Valid values:
|
description | No | The description of the compliance package. This parameter is used to describe the application scenarios of the compliance package. |
Example:
{
"compliancePackTemplate": {
"riskLevel": 1,
"compliancePackName": "BestPracticesForOSS",
"description": "Checks the compliance of read and write settings of storage space, protection settings, zone-redundant storage settings based on the best practice for the service."
}
}
configRuleTemplates
configRuleTemplates contains the rules in the compliance package. The rules are of the JSON ARRAY type. Syntax:
[
{
"configRuleName": "The name of the rule",
"scope": {
"complianceResourceTypes": [
"The resource types to which the rule is applicable"
]
},
"description": "The description of the rule",
"source": {
"owner": "The source of the rule",
"identifier": "The identifier of the rule",
"sourceDetails": [
{
"messageType": "The trigger type of the rule",
"maximumExecutionFrequency": "The interval at which the rule is triggered"
},
{
"messageType": "The trigger type of the rule"
}
],
"conditions": "The content of the condition rule"
},
"inputParameters": {
"paramName1": "The value of the paramName1 parameter",
"paramName2": "The value of the paramName2 parameter"
}
}
]
Parameter | Required | Description |
configRuleName | Yes | The name of the rule. |
scope.complianceResourceTypes | Yes | The resource types to which the rule is applicable. The value can be a JSON array. |
description | No | The description of the rule. |
source.owner | Yes | The source of the rule. Valid values:
|
source.identifier | Yes | The identifier of the rule. The value varies based on the source of the rule:
|
source.sourceDetails.messageType | Yes | The trigger type of the rule. Valid values:
|
source.sourceDetails.maximumExecutionFrequency | No | The interval at which the rule is triggered. Valid values:
Note This parameter is required if you set the |
source.conditions | No | The content of the condition rule. Note This parameter is required if you set the |
inputParameters | No | The input parameters of the rule. For information about the input parameters of a managed rule, click the corresponding link in Managed rules, and see the description of the Input parameter item in the Rule details section. All input parameters are of the STRING type. |
Example:
{
"configRuleTemplates": [
{
"configRuleName": "condition-rule-example",
"scope": {
"complianceResourceTypes": [
"ACS::ECS::Instance"
]
},
"description": "",
"source": {
"owner": "CUSTOM_CONFIGURATION",
"identifier": "acs-config-configuration",
"sourceDetails": [
{
"messageType": "ScheduledNotification",
"maximumExecutionFrequency": "Twelve_Hours"
},
{
"messageType": "ConfigurationItemChangeNotification"
}
],
"conditions": "{\"ComplianceConditions\":\"{\\\"operator\\\":\\\"and\\\",\\\"children\\\":[{\\\"operator\\\":\\\"GreaterOrEquals\\\",\\\"featurePath\\\":\\\"$.Cpu\\\",\\\"featureSource\\\":\\\"CONFIGURATION\\\",\\\"desired\\\":\\\"2\\\"}]}\"}"
},
"inputParameters": {}
},
{
"configRuleName": "oss-bucket-referer-limit",
"scope": {
"complianceResourceTypes": [
"ACS::OSS::Bucket"
]
},
"description": "If the hotlink protection feature is enabled for the OSS bucket and the Referer is added to a specified whitelist, the configuration is considered compliant.",
"source": {
"owner": "ALIYUN",
"identifier": "oss-bucket-referer-limit",
"sourceDetails": [
{
"messageType": "ConfigurationItemChangeNotification"
}
]
},
"inputParameters": {
"allowEmptyReferer": "true",
"allowReferers": "http://www.aliyun.com"
}
}
]
}
Example
{
"configRuleTemplates": [
{
"configRuleName": "condition-rule-example",
"scope": {
"complianceResourceTypes": [
"ACS::ECS::Instance"
]
},
"description": "",
"source": {
"owner": "CUSTOM_CONFIGURATION",
"identifier": "acs-config-configuration",
"sourceDetails": [
{
"messageType": "ScheduledNotification",
"maximumExecutionFrequency": "Twelve_Hours"
},
{
"messageType": "ConfigurationItemChangeNotification"
}
],
"conditions": "{\"ComplianceConditions\":\"{\\\"operator\\\":\\\"and\\\",\\\"children\\\":[{\\\"operator\\\":\\\"GreaterOrEquals\\\",\\\"featurePath\\\":\\\"$.Cpu\\\",\\\"featureSource\\\":\\\"CONFIGURATION\\\",\\\"desired\\\":\\\"2\\\"}]}\"}"
},
"inputParameters": {}
},
{
"configRuleName": "oss-bucket-referer-limit",
"scope": {
"complianceResourceTypes": [
"ACS::OSS::Bucket"
]
},
"description": "If the hotlink protection feature is enabled for the OSS bucket and the Referer is added to a specified whitelist, the configuration is considered compliant.",
"source": {
"owner": "ALIYUN",
"identifier": "oss-bucket-referer-limit",
"sourceDetails": [
{
"messageType": "ConfigurationItemChangeNotification"
}
]
},
"inputParameters": {
"allowEmptyReferer": "true",
"allowReferers": "http://www.aliyun.com"
}
}
],
"compliancePackTemplate": {
"riskLevel": 1,
"compliancePackName": "BestPracticesForOSS",
"description": "Checks the compliance of read and write settings of storage space, protection settings, zone-redundant storage settings based on the best practice for the service."
}
}
Import and export a compliance package template
You can import a compliance package template in a .json
or .txt
file to Cloud Config. You can also export a compliance package template in a .json
file. Then, you can share and back up the exported template. This helps you flexibly and conveniently manage rules.