Creates a rule for a specified account group. You can create a rule from a template or create a custom rule using Function Compute. The rule checks your resources for compliance. After a rule is created, it automatically runs once. Cloud Config then runs evaluations based on the rule's trigger. You can also run evaluations manually.
Operation description
Limits
Each management account and delegated administrator account can have a maximum of 200 rules.
Background information
Cloud Config supports the following methods for creating rules:
-
Create rules from templates
Rule templates are predefined rule functions that Cloud Config provides in Function Compute (FC). You can use rule templates to create rules quickly. For more information about rules, see Definition and working principle of rules.
-
Create rules based on functions in Function Compute
Custom function rules are rules whose code is hosted in FC functions. If the predefined rule templates in Cloud Config do not meet your compliance requirements, you can write function code to check compliance in complex scenarios. For more information about custom function rules, see Definition and working principle of custom function rules.
Usage notes
This example shows how to create a rule for the account group ca-a4e5626622af0079**** using the `required-tags` template. The response shows that the rule is created with the ID 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. |
存在所有指定标签 |
| Description |
string |
No |
The description of the rule. |
最多可以定义6组标签。如果资源同时具有指定的所有标签,则视为“合规”。 |
| InputParameters |
object |
No |
The input parameters of the rule. |
{"tag1Key":"ECS","tag1Value":"test"} |
| ConfigRuleTriggerTypes |
string |
Yes |
The trigger type of the rule. Valid values:
|
ConfigurationItemChangeNotification |
| MaximumExecutionFrequency |
string |
No |
The frequency at which the rule is run. Valid values:
Note
This parameter is required if you set |
One_Hour |
| ResourceTypesScope |
array |
Yes |
The resource types to be evaluated by the rule. Separate multiple resource types with commas (,). |
ACS::ECS::Instance |
|
string |
No |
The resource types 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:
|
1 |
| ClientToken |
string |
No |
A client token to ensure that the request is idempotent. Generate a unique value from your client for each request. The |
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 rule is effective only for resources in the specified regions. Separate multiple region IDs with commas (,). |
cn-hangzhou |
| ExcludeRegionIdsScope |
string |
No |
The rule is not effective for resources in the specified regions. The resources in the specified regions are not evaluated. Separate multiple region IDs with commas (,). |
cn-shanghai |
| ResourceIdsScope |
string |
No |
The rule is effective only for the specified resources. Separate multiple resource IDs with commas (,). |
lb-5cmbowstbkss9ta03**** |
| ExcludeResourceIdsScope |
string |
No |
The rule is not effective for the specified resources. The specified resources are not evaluated. Separate multiple resource IDs with commas (,). |
lb-t4nbowvtbkss7t326**** |
| ResourceGroupIdsScope |
string |
No |
The rule is effective only for resources in the specified resource groups. Separate multiple resource group IDs with commas (,). |
rg-aekzc7r7rhx**** |
| ExcludeResourceGroupIdsScope |
string |
No |
The rule is not effective for resources in the specified resource groups. The resources in the specified resource groups are not evaluated. Separate multiple resource group IDs with commas (,). |
rg-bnczc6r7rml**** |
TagKeyScope
deprecated
|
string |
No |
This parameter is deprecated. Use the The rule is effective only for resources that have the specified tag keys. Separate multiple tag keys with commas (,). Note
This parameter applies only to rule templates. The |
ECS |
TagValueScope
deprecated
|
string |
No |
This parameter is deprecated. Use the The rule is effective only for resources that have the specified tag values. Note
This parameter applies only to rule templates. The |
test |
| TagKeyLogicScope |
string |
No |
The logical relationship for multiple tags in the This parameter can also be used for the deprecated Valid values:
Valid values:
|
AND |
| TagsScope |
array<object> |
No |
The scope of the tags. |
|
|
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 scope of the tags to be excluded. |
|
|
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:
|
ALIYUN |
| SourceIdentifier |
string |
Yes |
The identifier of the rule.
|
required-tags |
| FolderIdsScope |
string |
No |
The rule is effective only for resources of the member accounts in the specified folders. Separate multiple folder IDs with commas (,). Note
|
fd-ZtHsRH**** |
| ExcludeFolderIdsScope |
string |
No |
The rule is not effective for resources of the member accounts in the specified folders. The resources of the member accounts in the specified folders are not evaluated. Separate multiple folder IDs with commas (,). Note
|
fd-pWmkqZ**** |
| ExcludeAccountIdsScope |
string |
No |
The rule is not effective for resources of the specified member accounts. The resources of the specified member accounts are not evaluated. Separate multiple member account IDs with commas (,). Note
This parameter applies only to rule templates. |
120886317861**** |
| AccountIdsScope |
string |
No |
The rule is effective only for resources of the specified member accounts. Separate multiple member account IDs with commas (,). Note
This parameter applies only to rule templates. |
115748125982**** |
| ExtendContent |
string |
No |
The extended content. This parameter specifies the trigger time for a rule that runs on a 24-hour cycle. |
{"fixedHour":"12"} |
| Tag |
array<object> |
No |
The tags to add to the rule. You can add up to 20 tags. |
|
|
object |
No |
The tag. |
||
| Key |
string |
No |
The key of the tag. You can add up to 20 tag keys. |
key-1 |
| Value |
string |
No |
The value of the tag. You can add up to 20 tag values. |
value-1 |
| ResourceNameScope |
string |
No |
The rule is effective only for resources that have the specified names. |
i-xxx |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
None |
||
| 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.