Creates a rule for an account group.

The sample request in this topic shows you how to create a rule based on the required-tags managed rule in the ca-a4e5626622af0079**** account group. The return result shows that the rule is created and its ID is cr-4e3d626622af0080****.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateAggregateConfigRule

The operation that you want to perform. Set the value to CreateAggregateConfigRule.

ConfigRuleName String Yes required-tags

The name of the rule.

Description String No If the resource has all the specified tags, the configuration is considered compliant. You can define up to 6 groups of tags.

The description of the rule.

InputParameters Map No null

The settings of the input parameters for the rule.

ConfigRuleTriggerTypes String Yes ConfigurationItemChangeNotification

The trigger type of the rule. Valid values:

  • ConfigurationItemChangeNotification: The rule is triggered by configuration changes.
  • ScheduledNotification: The rule is triggered as scheduled.
MaximumExecutionFrequency String No One_Hour

The interval at which the rule is triggered. Valid values:

  • One_Hour: 1 hour.
  • Three_Hours: 3 hours.
  • Six_Hours: 6 hours.
  • Twelve_Hours: 12 hours.
  • TwentyFour_Hours: 24 hours. This is the default value.
Note If the ConfigRuleTriggerTypes parameter is set to ScheduledNotification, this parameter is required.
ResourceTypesScope Array of String Yes ACS::ECS::Instance

The type of the resource to be evaluated. Separate multiple resource types with commas (,).

RiskLevel Integer Yes 1

The risk level of the resources that are not compliant with the rule. Valid values:

  • 1: high risk level.
  • 2: medium risk level.
  • 3: low risk level.
ClientToken String No 1594295238-f9361358-5843-4294-8d30-b5183fac****

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that it is unique among different requests. The client token can contain only ASCII characters. It cannot exceed 64 characters in length.

RegionIdsScope String No cn-hangzhou

The ID of the region to which the rule applies. Separate multiple region IDs with commas (,).

Note This parameter applies only to a rule that is to be created based on a managed rule.
ExcludeResourceIdsScope String No lb-t4nbowvtbkss7t326****

The ID of the resource to be excluded from the compliance evaluations performed by the rule. Separate multiple resource IDs with commas (,).

Note This parameter applies only to a rule that is to be created based on a managed rule.
AggregatorId String Yes ca-a4e5626622af0079****

The ID of the account group.

For more information about how to obtain the ID of an account group, see ListAggregators.

ResourceGroupIdsScope String No rg-aekzc7r7rhx****

The ID of the resource group to which the rule applies. Separate multiple resource group IDs with commas (,).

Note This parameter applies only to a rule that is to be created based on a managed rule.
TagKeyScope String No ECS

The tag key used to filter resources. The rule applies only to the resources with the specified tag key.

Note This parameter applies only to a rule that is to be created based on a managed rule. You must set the TagKeyScope and TagValueScope parameters at the same time.
TagValueScope String No test

The tag value used to filter resources. The rule applies only to the resources with the specified tag value.

Note This parameter applies only to a rule that is to be created based on a managed rule. You must set the TagKeyScope and TagValueScope parameters at the same time.
SourceOwner String Yes ALIYUN

The way in which the rule is to be created. Valid values:

  • ALIYUN: The rule is to be created based on a managed rule of Alibaba Cloud.
  • CUSTOM_FC: The rule is a custom rule.
SourceIdentifier String Yes required-tags

The identifier of the rule.

  • If the SourceOwner parameter is set to ALIYUN, set the value to the name of the managed rule.
  • If the SourceOwner parameter is set to CUSTOM_FC, set the value to the Alibaba Cloud Resource Name (ARN) of the relevant function in Function Compute.

For more information about how to query the name of a managed rule, see Managed rules.

For information about common request parameters, see Common parameters.

Response parameters

Parameter Type Example Description
ConfigRuleId String cr-4e3d626622af0080****

The ID of the rule.

RequestId String 5895065A-196C-4254-8AD8-14EFC31EEF50

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateAggregateConfigRule
&ConfigRuleName=required-tags
&ConfigRuleTriggerTypes=ConfigurationItemChangeNotification
&ResourceTypesScope=["ACS::ECS::Instance"]
&RiskLevel=1
&AggregatorId=ca-a4e5626622af0079****
&SourceOwner=ALIYUN
&SourceIdentifier=required-tags
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateAggregateConfigRuleResponse>
    <ConfigRuleId>cr-4e3d626622af0080****</ConfigRuleId>
    <RequestId>5895065A-196C-4254-8AD8-14EFC31EEF50</RequestId>
</CreateAggregateConfigRuleResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "ConfigRuleId" : "cr-4e3d626622af0080****",
  "RequestId" : "5895065A-196C-4254-8AD8-14EFC31EEF50"
}

Error codes

HTTP status code Error code Error message Description
400 ExceedMaxRuleCount The maximum number of rules is exceeded. The error message returned because the number of existing rules reaches the upper limit.
400 ConfigRuleNotExists The ConfigRule does not exist. The error message returned because the specified managed rule does not exist.
400 ConfigRuleExists The ConfigRule already exists. The error message returned because the specified rule name already exists.
400 Invalid.AggregatorId.Value The specified AggregatorId is invalid. The error message returned because the specified account group ID does not exist or you are not authorized to use the account group.
403 AggregatorMemberNoPermission The aggregator member is not authorized to perform the operation. The error message returned because you are using a member account and you are not authorized to perform the specified operation.
404 AccountNotExisted Your account does not exist. The error message returned because your account does not exist.
503 ServiceUnavailable The request has failed due to a temporary failure of the server. The error message returned because the service is unavailable.

For a list of error codes, visit the API Error Center.