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 default rules from a compliance package template, or select rules from rule templates and existing rule lists. After a compliance package is created, the rules run an evaluation by default. Subsequent evaluations are automatically triggered based on the trigger mechanism of each rule. You can also manually run an evaluation.
A compliance package template is a collection of rules that Cloud Config customizes for compliance scenarios.
This topic provides an example of how to create a compliance package by using the ClassifiedProtectionPreCheck compliance package template (classified protection precheck compliance package).
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
config:CreateCompliancePack |
create |
*CompliancePack
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| CompliancePackTemplateId |
string |
No |
The ID of the compliance package template. For information about how to obtain the compliance package template ID, see ListCompliancePackTemplates. |
ct-5f26ff4e06a300c4**** |
| CompliancePackName |
string |
Yes |
The name of the compliance package. |
Classified protection precheck compliance package |
| Description |
string |
No |
The description of the compliance package. |
Classified protection precheck compliance package |
| RiskLevel |
integer |
No |
The risk level of the compliance package. Valid values:
Valid values:
|
2 |
| ConfigRules |
array<object> |
No |
The list of rules in the compliance package. Note
You must specify either this parameter or |
|
|
array<object> |
No |
The list of rules in the compliance package. |
||
| 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 |
eip-bandwidth-limit |
| 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 |
bandwidth |
| ParameterValue |
string |
No |
The value of the rule parameter. The |
10 |
| ConfigRuleId |
string |
No |
The ID of the rule. Cloud Config adds the existing rule to the current compliance package. You must specify either |
cr-e918626622af000f**** |
| 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 |
| RiskLevel |
integer |
No |
The risk level of the rule. Valid values:
|
1 |
| TemplateContent |
string |
No |
The template information used to generate the compliance package. You can view the template content from the details API of an existing compliance package, or refer to Write a configuration-based compliance package template to compose the template. Note
You must specify either 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 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 client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The |
1594295238-f9361358-5843-4294-8d30-b5183fac**** |
| DefaultEnable |
boolean |
No |
Specifies whether the rule supports quick enablement. Valid values:
|
false |
| RegionIdsScope |
string |
No |
The compliance package takes effect only on resources in the specified region IDs. Separate multiple region IDs with commas (,). |
cn-hangzhou |
| ExcludeRegionIdsScope |
string |
No |
The excluded region IDs. Separate multiple region IDs with commas (,). |
cn-hangzhou |
| ExcludeResourceIdsScope |
string |
No |
The compliance package does not take effect on the specified resource IDs, which means the resources are not evaluated. Separate multiple resource IDs with commas (,). |
eip-8vbf3x310fn56ijfd**** |
| ResourceIdsScope |
string |
No |
The resource IDs for which the compliance package takes effect. Separate multiple resource IDs with commas (,). |
eip-8vbf3x310fn56ijfd**** |
| ResourceGroupIdsScope |
string |
No |
The compliance package takes effect only on resources in the specified resource group IDs. Separate multiple resource group IDs with commas (,). |
rg-aekzdibsjjc**** |
| ExcludeResourceGroupIdsScope |
string |
No |
The compliance package does not take effect on resources in the specified resource group IDs. Separate multiple resource group IDs with commas (,). |
rg-bnczc6r7rml**** |
| TagKeyScope |
string |
No |
The compliance package takes effect only on resources that are bound with the specified tag key. |
ECS |
| TagValueScope |
string |
No |
The compliance package takes effect only on resources that are bound with the specified tag key-value pair. Note
TagValueScope must be used together with TagKeyScope. |
test |
| 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. |
value-1 |
| ExcludeTagsScope |
array<object> |
No |
The excluded tag scope. |
|
|
object |
No |
The excluded tag scope. |
||
| TagKey |
string |
No |
The tag key. |
key-2 |
| TagValue |
string |
No |
The tag value. |
value-2 |
| Tag |
array<object> |
No |
The tags of the resource. You can bind up to 20 tags. |
|
|
object |
No |
The tags of the resource. You can bind up to 20 tags. |
||
| 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 parameters. |
||
| CompliancePackId |
string |
The ID of the compliance package. |
cp-a8a8626622af0082**** |
| RequestId |
string |
The request ID. |
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. |
| 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.