CreateAggregateConfigRule
Creates a rule based on a template or a custom rule based on Function Compute for a specified account group to check resource compliance. After the rule is created, an initial evaluation is automatically performed. Cloud Config then automatically triggers subsequent evaluations based on the trigger mechanism of the rule. You can also manually trigger evaluations.
Operation description
Limits
Each management account and delegated administrator account can create up to 200 rules.
Background information
Cloud Config allows you to create rules by using the following methods:
-
Create a rule based on a template
A rule template is a rule function built in Function Compute by Cloud Config. You can use rule templates to quickly create rules. For more information about rules, see Definition and working principle of rules.
-
Create a rule based on Function Compute
A custom Function Compute rule is a custom rule whose code is hosted in a Function Compute function. If the preset rule templates of Cloud Config cannot meet your requirements for checking resource compliance, you can write function code to check compliance in complex scenarios. For more information about custom Function Compute rules, see Definition and working principle of custom Function Compute rules.
Usage notes
This topic provides an example on how to create a rule for the account group ca-a4e5626622af0079**** by using the required-tags rule template. The response indicates that the rule is created and the rule ID is cr-4e3d626622af0080****.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
config:CreateAggregateConfigRule |
create |
*AggregateConfigRule
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ConfigRuleName |
string |
Yes |
The name of the rule. |
All specified tags exist |
| Description |
string |
No |
The description of the rule. |
You can define up to six tag key-value pairs. If a resource has all the specified tags, the resource is considered compliant |
| InputParameters |
object |
No |
The input parameters of the rule. |
{"tag1Key":"ECS","tag1Value":"test"} |
| ConfigRuleTriggerTypes |
string |
Yes |
The trigger mechanism of the rule. Valid values:
|
ConfigurationItemChangeNotification |
| MaximumExecutionFrequency |
string |
No |
The execution frequency of the rule. Valid values:
Note
You must set this parameter when ConfigRuleTriggerTypes is set to ScheduledNotification. Valid values:
|
One_Hour |
| ResourceTypesScope |
array |
Yes |
The types of resources to be evaluated by the rule. Separate multiple resource types with commas (,). |
ACS::ECS::Instance |
|
string |
No |
The types of resources to be evaluated by the rule. Separate multiple resource types with commas (,). |
ACS::ECS::Instance |
|
| RiskLevel |
integer |
Yes |
The risk level of the rule. Valid values:
Valid values:
|
1 |
| ClientToken |
string |
No |
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 the value is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. |
1594295238-f9361358-5843-4294-8d30-b5183fac**** |
| AggregatorId |
string |
Yes |
The ID of the account group. For more information about how to obtain the ID of an account group, see ListAggregators. |
ca-a4e5626622af0079**** |
| RegionIdsScope |
string |
No |
The IDs of the regions where the rule takes effect. The rule evaluates only the resources in the specified regions. Separate multiple region IDs with commas (,). |
cn-hangzhou |
| ExcludeRegionIdsScope |
string |
No |
The IDs of the regions where the rule does not take effect. The rule does not evaluate the resources in the specified regions. Separate multiple region IDs with commas (,). |
cn-shanghai |
| ResourceIdsScope |
string |
No |
The IDs of the resources to be evaluated by the rule. Separate multiple resource IDs with commas (,). |
lb-5cmbowstbkss9ta03**** |
| ExcludeResourceIdsScope |
string |
No |
The IDs of the resources that are not evaluated by the rule. Separate multiple resource IDs with commas (,). |
lb-t4nbowvtbkss7t326**** |
| ResourceGroupIdsScope |
string |
No |
The IDs of the resource groups where the rule takes effect. The rule evaluates only the resources in the specified resource groups. Separate multiple resource group IDs with commas (,). |
rg-aekzc7r7rhx**** |
| ExcludeResourceGroupIdsScope |
string |
No |
The IDs of the resource groups where the rule does not take effect. The rule does not evaluate the resources in the specified resource groups. Separate multiple resource group IDs with commas (,). |
rg-bnczc6r7rml**** |
TagKeyScope
deprecated
|
string |
No |
[Deprecated] Use the TagsScope parameter instead. The tag keys based on which the rule takes effect. The rule evaluates only the resources to which the specified tags are attached. Separate multiple tag keys with commas (,). Note
This parameter applies only to rule templates. You must set both TagKeyScope and TagValueScope at the same time. |
ECS |
TagValueScope
deprecated
|
string |
No |
[Deprecated] Use the TagsScope parameter instead. The tag values based on which the rule takes effect. The rule evaluates only the resources to which the specified tags are attached. Note
This parameter applies only to rule templates. You must set both TagKeyScope and TagValueScope at the same time. |
test |
| TagKeyLogicScope |
string |
No |
The logical relationship between multiple values of the TagsScope parameter. For example, if the TagsScope parameter is set to "TagsScope.1.TagKey":"a","TagsScope.1.TagValue":"a","TagsScope.2.TagKey":"b","TagsScope.2.TagValue":"b" and this parameter is set to AND, the rule takes effect only for resources to which both the a:a and b:b tags are attached. If you do not set this parameter, the default value OR is used. This parameter can also be used for the deprecated TagKeyScope parameter, which is not recommended. For example, if the TagKeyScope parameter is set to ECS,OSS and this parameter is set to AND, the rule takes effect only for resources to which both the ECS and OSS tags are attached. Valid values:
Valid values:
|
AND |
| TagsScope |
array<object> |
No |
The tag scope. |
|
|
object |
No |
|||
| TagKey |
string |
No |
The tag key of the resource. |
key-1 |
| TagValue |
string |
No |
The tag value of the resource. |
value-1 |
| ExcludeTagsScope |
array<object> |
No |
The excluded tag scope. |
|
|
object |
No |
|||
| TagKey |
string |
No |
The tag key of the resource to be excluded. |
key-2 |
| TagValue |
string |
No |
The tag value of the resource to be excluded. |
value-2 |
| SourceOwner |
string |
Yes |
The type of the rule. Valid values:
Valid values:
|
ALIYUN |
| SourceIdentifier |
string |
Yes |
The identifier of the rule.
|
required-tags |
| FolderIdsScope |
string |
No |
The IDs of the folders in the resource directory where the rule takes effect. The rule evaluates only the resources within the member accounts in the specified folders. Separate multiple folder IDs with commas (,). Note
|
fd-ZtHsRH**** |
| ExcludeFolderIdsScope |
string |
No |
The IDs of the folders in the resource directory where the rule does not take effect. The rule does not evaluate the resources within the member accounts in the specified folders. Separate multiple folder IDs with commas (,). Note
|
fd-pWmkqZ**** |
| ExcludeAccountIdsScope |
string |
No |
The IDs of the member accounts whose resources are not evaluated by the rule. Separate multiple member account IDs with commas (,). Note
This parameter applies only to rule templates. |
120886317861**** |
| AccountIdsScope |
string |
No |
The IDs of the member accounts whose resources are evaluated by the rule. Separate multiple member account IDs with commas (,). Note
This parameter applies only to rule templates. |
115748125982**** |
| Conditions |
string |
No |
The conditions of the custom condition rule in JSON format. |
{"ComplianceConditions":"{\"operator\":\"and\",\"children\":[{\"operator\":\"StringEquals\",\"featurePath\":\"$.Status\",\"desired\":\"1\",\"featureSource\":\"CONFIGURATION\"}]}"} |
| ExtendContent |
string |
No |
The extended content. This parameter is currently used only to set the trigger time for the 24-hour periodic trigger. |
{"fixedHour":"12"} |
| Tag |
array<object> |
No |
The tags of the created rule. |
|
|
object |
No |
The tag. |
||
| Key |
string |
No |
The tag key of the resource. You can attach up to 20 tag keys. |
key-1 |
| Value |
string |
No |
The tag value of the resource. You can attach up to 20 tag values. |
value-1 |
| ResourceNameScope |
string |
No |
The names of the resources to be evaluated by the rule. The rule takes effect only for the resources with the specified names. |
i-xxx |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The response. |
||
| ConfigRuleId |
string |
The ID of the rule. |
cr-4e3d626622af0080**** |
| RequestId |
string |
The ID of the request. |
5895065A-196C-4254-8AD8-14EFC31EEF50 |
Examples
Success response
JSON format
{
"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. | |
| 400 | ConfigRuleNotExists | The ConfigRule does not exist. | The rule does not exist. |
| 400 | ConfigRuleExists | The ConfigRule already exists. | |
| 400 | Invalid.AggregatorId.Value | The specified AggregatorId is invalid. | The specified aggregator ID does not exist or you are not authorized to use the aggregator. |
| 403 | AggregatorMemberNoPermission | The aggregator member is not authorized to perform the operation. | The aggregator member is not authorized to perform the operation. |
| 404 | AccountNotExisted | Your account does not exist. | |
| 503 | ServiceUnavailable | The request has failed due to a temporary failure of the server. | The request has failed due to a temporary failure of the server. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.