Rule
A rule mainly consists of a policy and an applicable scope, for example, some resources in a region.
You can use a JSON expression to represent a rule, as shown in Table 1.
Parameter |
Description |
Limitations |
Remarks |
---|---|---|---|
id |
Specifies the unique ID of a rule. |
N/A |
N/A |
policy_assignment_type |
Specifies the rule type. |
N/A |
The options are as follows:
If this parameter is not configured, builtin is used by default. |
name |
Specifies the rule name. |
Its value must be a string with up to 64 characters. |
By default, the rule name is the same as the selected policy name. You can customize the rule name. You can set a name of up to 64 characters. |
description |
Specifies supplementary information about the rule. |
Its value must be a string with up to 512 characters. |
By default, the rule description is the same as the description of the selected policy. You can customize the rule description. You can set the description of up to 512 characters. |
period |
Specifies how often the rule is executed. |
N/A |
Possible values are:
|
policy_filter |
Specifies the rule filter, which is used to filter the resources that will be evaluated by this rule. A filter has the following properties:
|
policy_filter: The value must be an object.
|
NOTE:
resource_provider is used to determine the filter type (Specific resources or All resources).
Therefore, no separate filter type property is set in policy_filter. |
state |
Specifies the rule status. |
N/A |
Possible values are:
|
created |
Specifies the time when the rule was created. |
N/A |
NOTE:
The time is a UTC time in a fixed format complying with ISO-8601 (for example, 2018-11-14T08:59:14Z). |
updated |
Specifies the time when the rule was updated. |
N/A |
|
policy_definition_id |
Specifies the ID of the compliance policy bound to the rule. |
Its value must be a string with up to 64 characters. Only letters, digits, and hyphens (-) are allowed. |
Policy ID |
custom_policy |
Custom policy, which contains the following attributes:
|
custom_policy: Its value is an object type.
|
custom_policy specifies the URN of the function in the custom policy and the authentication type for invoking the function. |
parameters |
Specifies the values of rule parameters. |
parameters: The value must be an object.
|
The compliance policy bound to the rule has corresponding parameters. The number, type, and value range of those parameters depend on the selected compliance policy. |
tags |
Tags added to a rule |
- |
|
created_by |
The creator of a rule |
- |
A rule can be created by a user or a service with the required service-link agency. |
You cannot create a rule to evaluate another rule or a conformance package.
The following shows a predefined policy that is used to check whether ECSs in regionid_1 have a specific tag (env: production).
{ "id": "5fcd8696dfb78231e6f2f899", "name": "required-tag-check", "description": "A resource is non-compliant if it does not contain the specific tag.", "policy_filter": { "region_id": "regionid_1", "resource_provider": "ecs", "resource_type": "cloudservers", "tag_key": "env", "tag_value": "production" }, "period": null, "state": "Enabled", "created": "2020-12-07T01:34:14.266Z", "updated": "2020-12-07T01:34:14.266Z", "policy_definition_id": "5fa9f89b6eed194ccb2c04db", "parameters": { "specifiedTagKey": { "value": "a" }, "specifiedTagValue": { "value": [] } } "tags": [], "created_by": "custom" }
The following JSON expression shows a custom rule for evaluating ECSs in regionid_1:
{ "id": "719d8696dfb78231e6f2f719", "name": "test_consume_policy", "description": "A resource is non-compliant if it does not contain the specific tag.", "policy_filter": { "region_id": "regionid_1", "resource_provider": "ecs", "resource_type": "cloudservers", "tag_key": null, "tag_value": null }, "period": null, "state": "Enabled", "created": "2022-07-19T01:34:14.266Z", "updated": "2022-07-19T01:34:14.266Z", "policy_definition_id": null, "custom_policy": { "function_urn": "urn:fss:regionid_1:projectidforpolicy:function:default:test_consume_policy:latest", "auth_type": "agency", "auth_value": {"agency_name": "rms_fg_agency"} }, "parameters": { "vpcId": {"value": "allowed-vpc-id"} } } "tags": [], "created_by": "custom" }
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