Assignments

Assignments are formed after you specify a compliance policy and the application scope of the compliance policy (for example, some resources in a region).

You can use a JSON expression to represent an assignment, as shown in Table 1.

Table 1 Assignment in JSON

Parameter

Description

Limitations

Remarks

id

Specifies the ID that uniquely identifies an assignment.

N/A

N/A

name

Specifies the assignment name.

Its value must be a string with up to 128 characters.

By default, the assignment name is the same as the selected policy name. You can customize the assignment name.

You can set a name of up to 128 characters.

description

Provides supplementary information about the assignment.

Its value must be a string with up to 512 characters.

By default, the assignment description is the same as the description of the selected policy. You can customize the assignment description.

You can set the description of up to 512 characters.

policy_filter

Specifies the assignment filter, which is used to filter the resources that will be evaluated by this assignment.

A filter has the following properties:

  • region_id: Specifies the region ID.
  • resource_provider: Specifies the service.
  • resource_type: Specifies the resource type of the service.
  • resource_id: Specifies the resource ID.
  • tag_key: Specifies the resource tag key.
  • tag_value: Specifies the resource tag value.
policy_filter: Its value must be an object.
  • region_id: Its value must be a string with up to 128 characters. Only letters, digits, and hyphens (-) are allowed.
  • resource_provider: Its value must be a string with up to 128 characters. Only letters and digits are allowed.
  • resource_type: Its value must be a string with up to 128 characters. Only letters and digits are allowed.
  • resource_id: Its value must be a string with up to 256 characters.
  • tag_key: Its value must be a string with up to 128 characters.
  • tag_value: Its value must be a string with up to 256 characters.
NOTE:

resource_provider is used to determine the filter type (Specific resources or All resources).

  • If resource_provider exists in policy_filter, the filter type is Specific resources.
  • If resource_provider does not exist in policy_filter, the filter type is All resources.

Therefore, no separate filter type property is set in policy_filter.

state

Specifies the assignment state.

N/A

Possible values are:

  • Enabled: The assignment is available.
  • Disabled: The assignment is disabled.
  • Evaluating: The assignment is being used for resource compliance evaluation.

created

Specifies the time when the assignment was created.

N/A

NOTE:

The time is a UTC time in a fixed format that complies with ISO-8601 (for example, 2018-11-14T08:59:14Z).

updated

Specifies the time when the assignment was updated.

N/A

policy_definition_id

Specifies the ID of the compliance policy bound to the assignment.

Its value must be a string with up to 64 characters. Only letters, digits, and hyphens (-) are allowed.

Each assignment must have a compliance policy bound. policy_definition_id specifies the ID of the compliance policy bound to the assignment.

parameters

Specifies the values of assignment parameters.

parameters: Its value must be an object.
  • The key of parameters must be a string with up to 64 characters. Only letters and digits are allowed.
  • The value of parameters must be an object, and the value restrictions vary depending on the parameter type.

The compliance policy bound to the assignment has corresponding parameters. The number, type, and value range of those parameters depend on the selected compliance policy.

The following JSON indicates an assignment used to check whether an ECS in region 1 has 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"
  },
  "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": []
    }
  }
}