All Products
Search
Document Center

Cloud Config:CreateConfigRule

Last Updated:Jun 17, 2024

Creates a rule for the current account.

Operation description

Limits

You can use a common account to create up to 200 rules.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
config:CreateConfigRuleWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
TagValueScopestringNo

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

Note This parameter applies only to managed rules. You must specify both TagKeyScope and TagValueScope.
test
DescriptionstringNo

The description of the rule.

TagKeyLogicScopestringNo

The logical relationship among the tag keys if you specify multiple tag keys for TagKeyScope. For example, if you set TagKeyScope to ECS,OSS and set TagKeyLogicScope to AND, the rule applies to resources with both the ECS and OSS tag keys. Valid values:

  • AND
  • OR
AND
SourceOwnerstringYes

The type of the rule Valid values:

  • ALIYUN: managed rule.
  • CUSTOM_FC: custom rule.
ALIYUN
MaximumExecutionFrequencystringNo

The intervals 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 (default): 24 hours.
Note This parameter is required if the ConfigRuleTriggerTypes parameter is set to ScheduledNotification.
One_Hour
RegionIdsScopestringNo

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

Note This parameter applies only to managed rules.
cn-hangzhou
ResourceGroupIdsScopestringNo

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

Note This parameter applies only to managed rules.
rg-aekzc7r7rhx****
InputParametersobjectNo

The input parameter of the rule.

{"tag1Key":"ECS","tag1Value":"test"}
TagKeyScopestringNo

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 managed rules. You must specify both TagKeyScope and TagValueScope.
ECS
ExcludeResourceIdsScopestringNo

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 managed rules.
lb-t4nbowvtbkss7t326****
SourceIdentifierstringYes

The ID of the rule.

  • If you set the SourceOwner parameter to ALIYUN, set this parameter to the name of the managed rule.
  • If you set the SourceOwner parameter to CUSTOM_FC, set this parameter 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.

required-tags
ConfigRuleTriggerTypesstringYes

The trigger type of the rule. Valid values:

  • ConfigurationItemChangeNotification: The rule is triggered by configuration changes.
  • ScheduledNotification: The rule is periodically triggered.
Note If a rule supports the preceding trigger types, separate the types with a comma (,).
ConfigurationItemChangeNotification
ConfigRuleNamestringYes

The name of the rule.

ClientTokenstringNo

The client token that you want to use to ensure the idempotency 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****
ResourceTypesScopearrayYes

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

stringYes

The type of the resource to be evaluated by the rule.

ACS::ECS::Instance
RiskLevelintegerYes

The risk level of the resources that do not comply with the rule. Valid values:

  • 1: high.
  • 2: medium.
  • 3: low.
1

For more information about common request parameters, see Common parameters.

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

ConfigRuleIdstring

The rule ID.

cr-5772ba41209e007b****
RequestIdstring

The request ID.

6EC7AED1-172F-42AE-9C12-295BC2ADB751

Examples

Sample success responses

JSONformat

{
  "ConfigRuleId": "cr-5772ba41209e007b****",
  "RequestId": "6EC7AED1-172F-42AE-9C12-295BC2ADB751"
}

Error codes

HTTP status codeError codeError messageDescription
400ExceedMaxRuleCountThe maximum number of rules is exceeded.The maximum number of rules is exceeded.
400ConfigRuleNotExistsThe ConfigRule does not exist.The rule does not exist.
400ConfigRuleExistsThe ConfigRule already exists.The config rule already exists.
404AccountNotExistedYour account does not exist.The specified account does not exist.
503ServiceUnavailableThe request has failed due to a temporary failure of the server.The request has failed due to a temporary failure of the server.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-12-18API Description Update. The Error code has changedsee changesets
Change itemChange content
API DescriptionAPI Description Update.
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404
    delete Error Codes: 503
2023-08-18The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404
    delete Error Codes: 503