Compliance Policies
A compliance policy is a static logical expression for resource compliance evaluation.
To make it take effect, you must specify a specific resource scope (by setting the filter), that is, generate a specific assignment.
You can use a JSON expression to represent a compliance policy, as shown in Table 1.
| Parameter | Description | Remarks |
|---|---|---|
| id | Specifies the ID that uniquely identifies a compliance policy. | N/A |
| name | Specifies the compliance policy name. | You can set a name of up to 128 characters. |
| description | Provides supplementary information about the compliance policy. | You can set the description of up to 512 characters. |
| parameters | Specifies the parameters (parameter names and values) contained in each compliance policy. parameters has the following properties:
| The parameter properties, such as name and description contained in the compliance policy remain unchanged, and you can set them to different values as needed. |
| name | Specifies the parameter name, which is used to distinguish multiple parameters. When you create a compliance policy, use name in policy_rule. When you add an assignment, specify the parameter values as required. | |
| description | Specifies the supplementary information about parameters. | |
| type | Specifies the type of the parameters value, which can be String, Array, Object, Boolean, Integer, Float, and Datetime. NOTE: Datetime is a UTC time in a fixed format complying with ISO-8601 (for example, 2018-11-14T08:59:14Z). | |
| default_value | Specifies the default value of parameters. If the default value is specified, you use the default value when you add an assignment. | |
| allowed_values | Specifies the list of allowed parameters values. If allowed_values is specified, you can only select the parameters values from the list. | |
| keywords | Specifies the compliance policy keywords. | Generally, it is the abbreviation of the product related to the compliance policy. |
| domain_id | Specifies the account ID. | domain_id of the built-in policies is null. |
| policy_type | Specifies the compliance policy type. Possible values are:
|
|
| policy_rule_type | Specifies the syntax type of the compliance policy. | Domain Specific Language (DSL): is a compliance policy description language provided by the RMS service. You can describe the compliance judgment logic as a specific compliance policy based on this syntax. |
| policy_rule | Specifies the logical expression of the compliance policy syntax. | For details about how to use DSL to write compliance policies, see DSL Syntax. |
The following JSON indicates a compliance policy used to check whether the image ID of an ECS is within the specified range.
{
"id": "5fa265c0aa1e6afc05a0ff07",
"name": "allowed-images-by-id",
"description": "An ECS image is non-compliant if its ID is not within the specific image ID range.",
"parameters": {
"listOfAllowedImages": {
"name": "listOfAllowedImages",
"description": "The list of allowed image IDs",
"type": "Array"
"allowed_values": null,
"default_value": null,
}
},
"keywords": [
"ecs",
"ims"
],
"domain_id": null,
"policy_type": "builtin",
"policy_rule_type": "dsl",
"policy_rule": {
"allOf": [
{
"value": "${resource().provider}",
"comparator": "equals",
"pattern": "ecs"
},
{
"value": "${resource().type}",
"comparator": "equals",
"pattern": "cloudservers"
},
{
"value": "${resource().properties.metadata.meteringImageId}",
"comparator": "notIn",
"pattern": "${parameters('listOfAllowedImages')}"
}
]
},
} For more examples, see Compliance Policy Examples.
Last Article: Resource Compliance Concepts
Next Article: Assignments
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.