All Products
Search
Document Center

Cloud Config:CreateCompliancePack

Last Updated:Oct 29, 2026

Creates a compliance package for the current account.

Operation description

A compliance package is a collection of rules. When you create a compliance package, you can select the default rules in a compliance package template, or select rules from rule templates and existing rule lists. After a compliance package is created, an evaluation is performed on these rules by default. Subsequent evaluations are automatically triggered based on the trigger mechanism of the rules, or you can manually perform evaluations.

A compliance package template is a collection of rules customized by Cloud Config based on compliance scenarios.

This topic provides an example of creating a compliance package by using the ClassifiedProtectionPreCheck (Classified Protection Precheck) compliance package template.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

config:CreateCompliancePack

create

*CompliancePack

acs:config:*:{#accountId}:compliancepack/*

None None

Request parameters

Parameter

Type

Required

Description

Example

CompliancePackTemplateId

string

No

Specifies whether to perform a dry run on the request. Valid values:

  • true: performs a dry run. The system checks the request parameters and related business logic, but does not perform the actual operation. If the dry run succeeds, the DryRunOperation error code is returned. If the dry run fails, the corresponding error code is returned.

  • false: performs the actual operation. This is the default value.

false

CompliancePackName

string

Yes

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****

Description

string

No

The name of the compliance package.

Classified Protection Precheck compliance package

RiskLevel

integer

No

The description of the compliance package.

Valid values:

  • 1 :

    High risk.

  • 2 :

    Medium risk.

  • 3 :

    Low risk.

Classified Protection Precheck compliance package

ConfigRules

array<object>

No

The risk level of the compliance package. Valid values:

  • 1: high risk.

  • 2: medium risk. This is the default value.

  • 3: low risk.

2

array<object>

No

The list of rules in the compliance package.

ConfigRuleId

string

No

The ID of the rule. Cloud Config adds the existing rule to the current compliance package.

You must specify either ManagedRuleIdentifier or ConfigRuleId. If both parameters are specified, ConfigRuleId takes precedence.

cr-e918626622af000f****

ConfigRuleName

string

No

The name of the rule.

The bandwidth of an EIP meets the minimum requirement

ConfigRuleParameters

array<object>

No

The information about the rule parameters.

object

No

The information about the rule parameters.

ParameterName

string

No

The name of the rule parameter.

The ParameterName and ParameterValue parameters must be specified together or left empty at the same time. If the rule template has parameters without default values, you must specify these parameters.

bandwidth

ParameterValue

string

No

The value of the rule parameter.

The ParameterName and ParameterValue parameters must be specified together or left empty at the same time. If the rule template has parameters without default values, you must specify these parameters.

10

Description

string

No

The description of the rule.

An elastic IP address that is associated with an ECS instance or NAT gateway and is not idle is considered compliant

ManagedRuleIdentifier

string

No

The identifier of the rule template. Cloud Config automatically creates a rule based on the rule template identifier and adds the rule to the current compliance package.

Note

You must set either ManagedRuleIdentifier or ConfigRuleId. If both parameters are set, ConfigRuleId takes precedence.

eip-bandwidth-limit

RiskLevel

integer

No

The risk level of the rule. Valid values:

  • 1: high risk.

  • 2: medium risk.

  • 3: low risk.

1

TemplateContent

string

No

The list of rules in the compliance package.

Note

You must specify this parameter or TemplateContent.

{ "configRuleTemplates": [ { "configRuleName": "Custom 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": "The Referer of an OSS bucket is in the specified anti-hotlinking whitelist", "scope": { "complianceResourceTypes": [ "ACS::OSS::Bucket" ] }, "description": "An OSS bucket with anti-hotlinking enabled and the Referer in the specified whitelist is considered compliant.", "source": { "owner": "ALIYUN", "identifier": "oss-bucket-referer-limit", "sourceDetails": [ { "messageType": "ConfigurationItemChangeNotification" } ] }, "inputParameters": { "allowEmptyReferer": "true", "allowReferers": "http://www.aliyun.com" } } ] }

ClientToken

string

No

The template information used to generate the compliance package. You can view the template content from the existing compliance package details API, or refer to Write a parameterized compliance package template to write the template.

Note

You must specify this parameter or ConfigRules.

{ "configRuleTemplates": [ { "configRuleName": "Custom 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": "The Referer of the OSS bucket is in the specified hotlink protection whitelist", "scope": { "complianceResourceTypes": [ "ACS::OSS::Bucket" ] }, "description": "Hotlink protection is enabled for the OSS bucket and the Referer is in the specified whitelist. In this case, the configuration is considered compliant.", "source": { "owner": "ALIYUN", "identifier": "oss-bucket-referer-limit", "sourceDetails": [ { "messageType": "ConfigurationItemChangeNotification" } ] }, "inputParameters": { "allowEmptyReferer": "true", "allowReferers": "http://www.aliyun.com" } } ] }

DefaultEnable

boolean

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 ensure that it is unique among different requests. The ClientToken can contain only ASCII characters and cannot exceed 64 characters in length.

1594295238-f9361358-5843-4294-8d30-b5183fac****

RegionIdsScope

string

No

Specifies whether the rule supports quick enabling. Valid values:

  • true: The rule is enabled when the compliance package is quickly enabled.

  • false: The rule is not enabled. This is the default value.

false

ExcludeRegionIdsScope

string

No

The compliance package takes effect only for resources in the specified region IDs. Separate multiple region IDs with commas (,).

cn-hangzhou

ExcludeResourceIdsScope

string

No

The excluded region scope. Separate multiple region IDs with commas (,).

cn-hangzhou

ResourceIdsScope

string

No

The compliance package does not take effect for the specified resource IDs, which means that no evaluation is performed on these resources. Separate multiple resource IDs with commas (,).

eip-8vbf3x310fn56ijfd****

ResourceGroupIdsScope

string

No

The resource scope where the compliance package takes effect. Separate multiple resource IDs with commas (,).

eip-8vbf3x310fn56ijfd****

ExcludeResourceGroupIdsScope

string

No

The compliance package takes effect only for resources in the specified resource group IDs. Separate multiple resource group IDs with commas (,).

rg-aekzdibsjjc****

TagKeyScope

string

No

The compliance package does not take effect for resources in the specified resource group IDs. Separate multiple resource group IDs with commas (,).

rg-bnczc6r7rml****

TagValueScope

string

No

The compliance package takes effect only for resources that are bound with the specified tag key.

ECS

TagsScope

array<object>

No

The compliance package takes effect only for resources that are bound with the specified tag key-value pair.

Note

TagValueScope must be used together with TagKeyScope.

test

object

No

TagKey

string

No

The tag key of the resource.

key-1

TagValue

string

No

The tag value.

value-1

ExcludeTagsScope

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.

value-1

Tag

array<object>

No

The excluded tag scope.

object

No

The excluded tag scope.

Key

string

No

The tag key of the resource.

You can bind up to 20 tag keys.

key-1

Value

string

No

The tag value of the resource.

You can bind up to 20 tag values.

value-1

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

Response elements

Element

Type

Description

Example

object

The response.

CompliancePackId

string

The ID of the compliance package.

cp-a8a8626622af0082****

RequestId

string

The ID of the request.

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

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

400 CompliancePackExceedMaxCount The maximum number of compliance pack is exceeded.
400 Invalid.ConfigRules.Empty You must specify ConfigRules.
400 Invalid.ConfigRules.Value The specified ConfigRules is invalid. The specified ConfigRules is invalid.
400 ConfigRuleExceedMaxRuleCount The maximum number of config rules is exceeded.
400 Invalid.CompliancePackName.Empty You must specify CompliancePackName. You must specify compliance pack name.
400 Invalid.CompliancePackName.Value The specified CompliancePackName is invalid. The specified compliance pack name is invalid.
400 Invalid.CompliancePackTemplateId.Value The specified CompliancePackTemplateId does not exist. The specified compliance pack template ID does not exist.
400 CompliancePackExists The compliance pack already exists. The compliance pack name already exists.
400 DryRunOperation Request validation has been passed with DryRun flag set.
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.