Creates a desired-state configuration.


OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateStateConfiguration

The operation that you want to perform. Set the value to CreateStateConfiguration.

ScheduleExpression String Yes 1 hour or 30 minutes

The schedule expression. The interval between two schedules must be a minimum of 30 minutes.

ScheduleType String Yes rate

The type of the schedule. Valid value: rate.

Targets String Yes { "ResourceType": "ALIYUN::ECS::Instance", "Filters": [ { "Type": "All", "RegionId": "cn-hangzhou", "Parameters": { "RegionId": "cn-hangzhou", "Status": "Running" } } ] }

The required resources.

TemplateName String Yes ACS-ECS-InventoryDataCollection

The name of the template. The name must be 1 to 200 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

RegionId String No cn-hangzhou

The region ID.

Description String No Collect data that is specified in the configuration list.

The description of the desired-state configuration.

TemplateVersion String No v1

The version number. If you do not specify this parameter, the system uses the latest version.

Parameters String No { "policy": { "ACS:Application": { "Collection": "Enabled" }, "ACS:Network": { "Collection": "Enabled" } } }

The parameters.

ConfigureMode String No ApplyOnce

The configuration mode.

ApplyOnce: The configuration is applied only once. After a configuration is updated, the new configuration is applied.

ApplyAndMonitor: The configuration is applied only once. After the configuration is applied, the system only checks whether the configuration is migrated in the future.

ApplyAndAutoCorrect: The configuration is always applied.


The idempotency token.

Tags Json No {"Key": "oos", "Value": "inventory"}

The tag.

Response parameters

Parameter Type Example Description
RequestId String 1306108F-610C-40FD-AAD5-DA13E8B00BE9

The ID of the request.

StateConfiguration Struct

The desired-state configuration.

ConfigureMode String ApplyAndAutoCorrect

The configuration mode.

CreateTime String 2021-03-22T03:13:32Z

The creation time.

Description String Collect data that is specified in the configuration list.

The description.

Parameters Map {"policy": {"ACS:Network": {"Collection": "Enabled"}, "ACS:Application": {"Collection": "Enabled"}}}

The parameters.

ScheduleExpression String 1 hour

The schedule expression.

ScheduleType String rate

The schedule type.

StateConfigurationId String sc-a538febe18fabcdef

The ID of the desired-state configuration.

Tags Map {"Key": "oos", "Value": "inventory"}

The tag.

Targets String { "ResourceType": "ALIYUN::ECS::Instance", "Filters": [ { "Type": "All", "RegionId": "cn-hangzhou", "Parameters": { "RegionId": "cn-hangzhou", "Status": "Running" } } ] }

The required resources.

TemplateId String t-1234asadf

The ID of the template.

TemplateName String ACS-ECS-InventoryDataCollection

The name of the template.

TemplateVersion String v1

The version of the template.


Sample requests

&ScheduleExpression=1 hour
&Targets={     "ResourceType": "ALIYUN::ECS::Instance",     "Filters": [       {         "Type": "All",         "RegionId": "cn-hangzhou",         "Parameters": {           "RegionId": "cn-hangzhou",           "Status": "Running"         }       }     ]   }
&<Common request parameters>

Sample success responses

XML format

    <ScheduleExpression>1 hour</ScheduleExpression>
    <Parameters>{"policy": {"ACS:Network": {"Collection": "Enabled"}, "ACS:Application": {"Collection": "Enabled"}}}</Parameters>
    <Description>test sc</Description>
    <Targets>{     "ResourceType": "ALIYUN::ECS::Instance",     "Filters": [       {         "Type": "All",         "RegionId": "cn-hangzhou",         "Parameters": {           "RegionId": "cn-hangzhou",           "Status": "Running"         }       }     ]   }</Targets>
    <Tags>{"Key": "oos", "Value": "inventory"}</Tags>

JSON format

{"RequestId":"1306108F-610C-40FD-AAD5-DA13E8B00BE9","StateConfiguration":{"ConfigureMode":"ApplyAndAutoCorrect","ScheduleExpression":"1 hour","ScheduleType":"rate","Parameters":"{\"policy\": {\"ACS:Network\": {\"Collection\": \"Enabled\"}, \"ACS:Application\": {\"Collection\": \"Enabled\"}}}","Description":"test sc","StateConfigurationId":"sc-a538febe18fabcdef","CreateTime":"2021-03-22T03:13:32Z","TemplateVersion":"v1","TemplateName":"ACS-ECS-InventoryDataCollection","Targets":"{     \"ResourceType\": \"ALIYUN::ECS::Instance\",     \"Filters\": [       {         \"Type\": \"All\",         \"RegionId\": \"cn-hangzhou\",         \"Parameters\": {           \"RegionId\": \"cn-hangzhou\",           \"Status\": \"Running\"         }       }     ]   }","Tags":"{\"Key\": \"oos\", \"Value\": \"inventory\"}","TemplateId":"t-1234asadf"}}

Error codes

For a list of error codes, visit the API Error Center.