This topic describes how to use the compliance package template BestPracticesForECS to quickly check the compliance of Elastic Compute Service (ECS) instances and deliver resource non-compliance events to Simple Log Service. This example helps you learn how to use Cloud Config to check the resource compliance of an Alibaba Cloud account.
Prerequisites
You are using an independent Alibaba Cloud account that is not added to a resource directory by a management account.
Cloud Config is activated. For more information, see Activate Cloud Config.
An ECS instance is created. For more information, see Creation methods.
Simple Log Service is activated. For more information, see Activate Simple Log Service.
ImportantYou are not charged when you activate Simple Log Service. Cloud Config delivers resource data to Simple Log Service, and you are charged if you use the query and analysis features of Simple Log Service. For more information, see Billing overview.
Step 1: View the resource list
After you create an ECS instance in the ECS console, the ECS instance is displayed as a resource on the Global Resources page of the Cloud Config console.
Log on to the Cloud Config console.
In the left-side navigation pane, choose
.On the Global Resources page, enter the corresponding resource ID or set filter conditions to query the specified resource.
Step 2: Create a compliance package
You can use the default rules in the compliance package template BestPracticesForECS to quickly check the compliance of the ECS instance.
In the left-side navigation pane, choose
.On the Compliance Package page, click Create Package.
In the Select Template (Optional) step, find the compliance package template BestPracticesForECS, click the icon, and then click Next.
In the Set Basic Properties step, set the name of the compliance package and keep the default values for other parameters. Then, click Next.
In the Select Rules step, select all rules from the compliance package template BestPracticesForECS and click Next.
In the Set Rule Parameters step, set the parameters for the rules and click OK.
NoteFor more information about how to set parameters for the rules, see the Resource type column in Alibaba Cloud services and resource types supported by Cloud Config.
Step 3: View the compliance evaluation results
You can view the evaluation results of the rules in the compliance package and remediate the non-compliant resources.
In the left-side navigation pane, choose
.On the Compliance Package page, click the ID of the compliance package created in Step 2.
Click Download Report in the upper-right corner of the page that appears. In the Download Compliance Report message, click OK.
Download the compliance report in the Excel format.
Open the compliance report in the Excel format. On the Non-compliant Resources tab, filter all non-compliant rules by ECS instance ID and perform remediation based on the Remediation Suggestions column.
Step 4: Deliver resource non-compliance events to Simple Log Service
You can configure the delivery of resource non-compliance events to a specified Logstore of Simple Log Service, and query and analyze the events.
On the Deliveries page, click Create Delivery in the upper-left corner.
On the Create Delivery page, set Delivery Name, select Log Service for Channel Type, Noncompliance Resource Events for Content, and Create a new log item in this account for Logstore Source, select an option from the Project Region drop-down list, and then set Project Name and Logstore Name. Retain the default values for Events Of Specified Resource Type, that is, retain all resource types.
Click OK.
In the Simple Log Service console, a Simple Log Service project is automatically created. A Logstore is automatically created under the project. Resource non-compliance events in Cloud Config are delivered to this Logstore.
ImportantCloud Config delivers resource data to Simple Log Service, and you are charged if you use the query and analysis features of Simple Log Service. If you do not want to incur fees, you can delete the Simple Log Service project in the Simple Log Service console. After you delete the Simple Log Service project, the delivery task in Cloud Config becomes invalid and the resource data is no longer delivered. For more information, see Delete a project.
View the delivery results of resource non-compliance events, and query and analyze them.
On the Deliveries page, click the newly created delivery ID.
In the Extended Information section of the page that appears, click the name of the Logstore.
You are redirected to the destination Logstore page in the Simple Log Service console.
In the Error message, click Close.
NoteThe indexing feature is not enabled for a Logstore created in the Cloud Config console by default, and the system reports an error.
Enable the indexing feature for the Logstore.
For more information, see Create indexes.
Query and analyze logs in the Logstore.
For more information, see Query and analyze logs.
NoteFor more information about the example files in the JSON format for resource non-compliance events, see Example of resource non-compliance events.