Policy
A policy is a logical expression used to evaluate resource compliance.
A policy cannot work on its own. Instead, you need to attach a policy to a rule.
A policy can be a JSON expression. Table 1 lists policy (JSON expression) parameters.
Parameter |
Description |
Remarks |
---|---|---|
id |
Policy ID |
N/A |
name |
Policy name |
A policy name can contain up to 64 characters. |
display_name |
Display name of a policy |
A policy display name can contain up to 64 characters. |
description |
Policy description |
Policy description can contain up to 512 characters. |
parameters |
Policy parameters The following attributes are used to describe each policy parameter:
|
The parameter names, such as name and description contained in the compliance policy remain unchanged.
|
keywords |
Policy keywords |
Generally, the name abbreviation of the related product is used as a keyword. |
policy_type |
Policy type The options are as follows:
|
|
policy_rule_type |
Policy syntax |
Domain Specific Language (DSL): provided by Config to write policy expressions. |
trigger_type |
Trigger type. The options are as follows:
|
|
default_resource_types |
Resource type |
Most policies only apply to a limited scope of resources. You are advised to use a rule to only evaluate resource types in default_resource_types. |
The following is an example policy used to check whether specified images are used for ECSs.
{ "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": "null", "description": "The list of allowed image IDs", "type": "Array" "allowed_values": null, "default_value": null, } }, "keywords": [ "ecs", "ims" ], "policy_type": "builtin", "policy_rule_type": "dsl", "trigger_type": "resource", "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 Example Custom Rules.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot