All Products
Search
Document Center

Cloud Config:CreateCompliancePack

Last Updated:Mar 01, 2024

Creates a compliance package for the current account.

Operation description

Each ordinary account can create up to five compliance packages.

This topic provides an example on how to create a compliance package named ClassifiedProtectionPreCheck. The compliance package contains a managed rule named eip-bandwidth-limit.

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:CreateCompliancePackWrite
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
CompliancePackTemplateIdstringNo

The ID of the compliance package template.

For more information about how to obtain the ID of a compliance package template, see ListCompliancePackTemplates .

ct-5f26ff4e06a300c4****
CompliancePackNamestringYes

The name of the compliance package.

test-pack-name
DescriptionstringNo

The description of the compliance package.

Test pack description.
RiskLevelintegerNo

The risk level of the resources that are not compliant with the rules in the compliance package. Default value: 2. Valid values:

  • 1: high risk level.
  • 2: medium risk level.
  • 3: low risk level.
1
ConfigRulesobject []No

The rules in the compliance package. You must specify either this parameter or TemplateContent.

ManagedRuleIdentifierstringNo

The ID of the managed rule. Cloud Config automatically creates a managed rule based on the specified ID and adds the rule to the compliance package.

You need to only specify one of ManagedRuleIdentifier and ConfigRuleId. If you specify both parameters, the value of ConfigRuleId takes precedence. You can call the ListCompliancePackTemplates operation to obtain the managed rule ID.

eip-bandwidth-limit
ConfigRuleNamestringNo

The rule name.

eip-bandwidth-limit
ConfigRuleParametersobject []No

The input parameters of the rule.

ParameterNamestringNo

The name of the input parameter.

You must specify both ParameterName and ParameterValue or neither of them. If the managed rule has an input parameter but no default value is specified, you must specify this parameter. For more information about how to obtain the name of the input parameter of a managed rule, see ListCompliancePackTemplates .

bandwidth
ParameterValuestringNo

The value of the input parameter.

You must specify both ParameterName and ParameterValue or neither of them. If the managed rule has an input parameter but no default value is specified, you must specify this parameter. For more information about how to obtain the value of the input parameter of a managed rule, see ListCompliancePackTemplates .

10
ConfigRuleIdstringNo

The ID of the rule. If you specify this parameter, Cloud Config adds the rule of the specified ID to the compliance package.

You need to only specify one of ManagedRuleIdentifier and ConfigRuleId. If you specify both parameters, the value of ConfigRuleId takes precedence. You can call the ListConfigRules operation to obtain the rule ID.

cr-e918626622af000f****
DescriptionstringNo

The description of the rule.

The description of the test rule.
RiskLevelintegerNo

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

  • 1: high risk level.
  • 2: medium risk level.
  • 3: low risk level.
1
TemplateContentstringNo

The information about the template that is used to create the compliance package. You can view the template content of an existing compliance package by calling the GetCompliancePack operation. You can also write a template. For more information, see Write a compliance package template in a configuration file. You must specify either this parameter or ConfigRules.

{ "configRuleTemplates": \[ { "configRuleName": "condition-rule-example", "scope": { "complianceResourceTypes": \[ "ACS::ECS::Instance" ] }, "description": "", "source": { "owner": "CUSTOM_CONFIGURATION", "identifier": "acs-config-configuration", "sourceDetails": \[ { "messageType": "ScheduledNotification", "maximumExecutionFrequency": "Twelve_Hours" }, { "messageType": "ConfigurationItemChangeNotification" } ], "conditions": "{\\"ComplianceConditions\\":\\"{\\\\\"operator\\\\\":\\\\\"and\\\\\",\\\\\"children\\\\\":\[{\\\\\"operator\\\\\":\\\\\"GreaterOrEquals\\\\\",\\\\\"featurePath\\\\\":\\\\\"$.Cpu\\\\\",\\\\\"featureSource\\\\\":\\\\\"CONFIGURATION\\\\\",\\\\\"desired\\\\\":\\\\\"2\\\\\"}]}\\"}" }, "inputParameters": {} }, { "configRuleName": "oss-bucket-referer-limit", "scope": { "complianceResourceTypes": \[ "ACS::OSS::Bucket" ] }, "description": "If the hotlink protection feature is enabled for the Object Storage Service (OSS) bucket and the Referer is added to a specific whitelist, the evaluation result is compliant.", "source": { "owner": "ALIYUN", "identifier": "oss-bucket-referer-limit", "sourceDetails": \[ { "messageType": "ConfigurationItemChangeNotification" } ] }, "inputParameters": { "allowEmptyReferer": "true", "allowReferers": "http://www.aliyun.com" } } ] }
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 ensure that it 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****
DefaultEnablebooleanNo

Specifies whether to enable the rule together with the compliance package. Valid values:

  • true: The system enables the rule together with the compliance package.
  • false: The system does not enable the rule together with the compliance package.
false
RegionIdsScopestringNo

The ID of the region whose resources you want to evaluate by using the compliance package. Separate multiple region IDs with commas (,).

cn-hangzhou
ExcludeResourceIdsScopestringNo

The ID of the resource that you do not want to evaluate by using the compliance package. Separate multiple resource IDs with commas (,).

eip-8vbf3x310fn56ijfd****
ResourceGroupIdsScopestringNo

The ID of the resource group whose resources you want to evaluate by using the compliance package. Separate multiple resource group IDs with commas (,).

rg-aekzdibsjjc****
TagKeyScopestringNo

The tag key of the resource that you want to evaluate by using the compliance package.

ECS
TagValueScopestringNo

The tag value of the resource that you want to evaluate by using the compliance package.

Note You must configure the TagValueScope parameter together with the TagKeyScope parameter.
test

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

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

CompliancePackIdstring

The ID of the compliance package.

cp-a8a8626622af0082****
RequestIdstring

The request ID.

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

Examples

Sample success responses

JSONformat

{
  "CompliancePackId": "cp-a8a8626622af0082****",
  "RequestId": "6EC7AED1-172F-42AE-9C12-295BC2ADB751"
}

Error codes

HTTP status codeError codeError messageDescription
400CompliancePackExceedMaxCountThe maximum number of compliance pack is exceeded.The maximum number of compliance pack is exceeded.
400Invalid.ConfigRules.EmptyYou must specify ConfigRules.You must specify ConfigRules.
400Invalid.ConfigRules.ValueThe specified ConfigRules is invalid.The specified ConfigRules is invalid.
400ConfigRuleExceedMaxRuleCountThe maximum number of config rules is exceeded.The maximum number of config rules is exceeded.
400Invalid.CompliancePackName.EmptyYou must specify CompliancePackName.You must specify compliance pack name.
400Invalid.CompliancePackName.ValueThe specified CompliancePackName is invalid.The specified compliance pack name is invalid.
400Invalid.CompliancePackTemplateId.ValueThe specified CompliancePackTemplateId does not exist.The specified compliance pack template ID does not exist.
400CompliancePackExistsThe compliance pack already exists.The compliance pack name 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-13The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 404
    delete Error Codes: 503
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: TemplateContent