As the smallest unit of operations, an action defines a specific operation.
Action types
Actions can be divided into the following types:
- Atom actions:
- API actions
- Trigger actions
- Control actions
- Embedding actions
- Cloud product actions:
- Elastic Compute Service (ECS) actions
- Relational Database Service (RDS) actions
- DingTalk actions
Name format
The format of an action name is ACS::<name>
.
General attributes
Unless otherwise specified, each action has the following attributes:
---
Tasks:
- Name: task_name_1
Action: 'Action'
Description: describe the purpose of the task
OnError: 'END/CONTINUE/<other-task-name>' # The process to be executed if an error occurs when the task is executed. Default value: END, indicating that the execution will end when an error occurs.
OnSuccess: 'NEXT/<other-task-name>/END' # The process to be executed when the task is successfully executed. Default value: NEXT, indicating that the next task will be executed after the current task is successfully executed.
Properties:
Service: ECS/RDS/RAM
Risk: High/Normal
API: DeleteInstance/CreateDBInstance/CreateRamRole
Parameters:
InstanceId: "i-XXX"
Outputs:
Output_parameter_name_1:
Type: String/List
Value: {{ task.output1 }}
Common attributes
- Name: the name of the task. The name can contain [a-zA-Z0-9-], including lowercase letters, uppercase letters, digits, underscores (), and hyphens (-). It can be up to 200 characters in length, and cannot contain colons (:).
- Action: the action of the task. The value must be an atom action or a cloud product action. It must start with
ACS::
. - Description: the usage of the current task.
- Properties: the properties of the task. For more information, see ACS::ExecuteAPI.
Security risk settings
If you have set the risk level for important cloud products, such as Elastic Compute Service (ECS) and Relational Database Service (RDS), in the template, the template is executed based on the specified risk level. If you have not set the risk level, the template is executed based on the default security risk settings of Operation Orchestration Service (OOS).By default, the Risk attribute is set to High for all API operations whose names start with Delete, Remove, Terminate, and Drop.
Example
The following template is used to delete an ECS instance. If the value of Risk is Normal, the ECS instance can be deleted immediately. If the value of Risk is not Normal, the execution enters the Waiting status.
- YAML format
---
FormatVersion: OOS-2019-06-01
Description: delete instance
Parameters:
InstanceId:
Description: the instance id that you will delete
Type: String
Tasks:
- Name: deleteInstance
Action: ACS::ExecuteAPI
Description: delete instance with specified parameters
Properties:
Service: ECS
API: DeleteInstance
Risk: Normal
Parameters:
InstanceId: "{{ InstanceId }}"
Outputs:
RequestId:
Type: String
ValueSelector: RequestId
Outputs:
RequestId:
Type: String
Value: "{{ deleteInstance.RequestId }}"
- JSON format
{
"FormatVersion": "OOS-2019-06-01",
"Description": "delete instance",
"Parameters": {
"InstanceId": {
"Description": "the instance id that you will delete",
"Type": "String"
}
},
"Tasks": [
{
"Name": "deleteInstance",
"Action": "ACS::ExecuteAPI",
"Description": "delete instance with specified parameters",
"Properties": {
"Service": "ECS",
"API": "DeleteInstance",
"Risk": "Normal",
"Parameters": {
"InstanceId": "{{ InstanceId }}"
}
},
"Outputs": {
"RequestId": {
"Type": "String",
"ValueSelector": "RequestId"
}
}
}
],
"Outputs": {
"RequestId": {
"Type": "String",
"Value": "{{ deleteInstance.RequestId }}"
}
}
}
Process control attributes
OnError: ACS::END
: The execution will end when an error occurs on the current task.OnSuccess: ACS::NEXT
: The next task will be executed when the current task is successfully executed.OnError: CONTINUE
: The next task will be executed when an error occurs on the current task.OnError: <task_name>
: The specified task will be executed when an error occurs on the current task.OnSuccess:<task_name>
: The specified task will be executed when the current task is successfully executed.
Example
The following template is used to create an ECS instance and install Cloud Assistant on the instance. If the installation fails, the instance will be automatically deleted.
- YAML format
---
FormatVersion: OOS-2019-06-01
Parameters:
SourceImageId:
Description: the image id of the source image to be updated
Type: String
InstanceType:
Description: the Instance Type for the new instances
Type: String
SecurityGroupId:
Description: the security group id for the new instances
Type: String
VSwitchId:
Description: the virtual switch id for the new instances
Type: String
OOSAssumeRole:
Type: String
Description: oos assume this role to execution task
Default: OOSServiceRole
RamRole: "{{OOSAssumeRole}}"
Tasks:
- Name: runInstances
Action: ACS::ECS::RunInstances
Properties:
ImageId: "{{ SourceImageId }}"
InstanceType: "{{ InstanceType }}"
SecurityGroupId: "{{ SecurityGroupId }}"
VSwitchId: "{{ VSwitchId }}"
Outputs:
InstanceId:
ValueSelector: InstanceIds[0]
Type: String
- Name: installCloudAssistant
Action: ACS::ECS::InstallCloudAssistant
OnError: deleteInstance
Properties:
InstanceId: "{{ runInstances.InstanceId }}"
- Name: deleteInstance
Action: ACS::ExecuteApi
Properties:
Service: ECS
API: DeleteInstance
Risk: Normal
Parameters:
InstanceId: "{{ runInstances.InstanceId }}"
Force: true
Outputs:
InstanceId:
Type: String
Value: "{{ runInstances.InstanceId }}"
- JSON format
{
"FormatVersion": "OOS-2019-06-01",
"Parameters": {
"SourceImageId": {
"Description": "the image id of the source image to be updated",
"Type": "String"
},
"InstanceType": {
"Description": "the Instance Type for the new instances",
"Type": "String"
},
"SecurityGroupId": {
"Description": "the security group id for the new instances",
"Type": "String"
},
"VSwitchId": {
"Description": "the virtual switch id for the new instances",
"Type": "String"
},
"OOSAssumeRole": {
"Type": "String",
"Description": "oos assume this role to execution task",
"Default": "OOSServiceRole"
}
},
"RamRole": "{{OOSAssumeRole}}",
"Tasks": [
{
"Name": "runInstances",
"Action": "ACS::ECS::RunInstances",
"Properties": {
"ImageId": "{{ SourceImageId }}",
"InstanceType": "{{ InstanceType }}",
"SecurityGroupId": "{{ SecurityGroupId }}",
"VSwitchId": "{{ VSwitchId }}"
},
"Outputs": {
"InstanceId": {
"ValueSelector": "InstanceIds[0]",
"Type": "String"
}
}
},
{
"Name": "installCloudAssistant",
"Action": "ACS::ECS::InstallCloudAssistant",
"OnError": "deleteInstance",
"Properties": {
"InstanceId": "{{ runInstances.InstanceId }}"
}
},
{
"Name": "deleteInstance",
"Action": "ACS::ExecuteApi",
"Properties": {
"Service": "ECS",
"API": "DeleteInstance",
"Risk": "Normal",
"Parameters": {
"InstanceId": "{{ runInstances.InstanceId }}",
"Force": true
}
}
}
],
"Outputs": {
"InstanceId": {
"Type": "String",
"Value": "{{ runInstances.InstanceId }}"
}
}
}
Task output attributes
Task output attributes include Type and ValueSelector. If there are multiple output items, separate them with commas (,). For more information, see the syntax in the following example.
Example
The following template is used to obtain all the instances in the Running status under the account:
- YAML format
---
FormatVersion: OOS-2019-06-01
Tasks:
- Name: describeInstances
Action: ACS::ExecuteAPI
Properties:
Service: ECS
API: DescribeInstances
Parameters:
Status: "Running"
Outputs:
InstanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
Outputs:
InstanceIds:
Type: String
Value: "{{ describeInstances.InstanceIds }}"
- JSON format
{
"FormatVersion": "OOS-2019-06-01",
"Tasks": [
{
"Name": "describeInstances",
"Action": "ACS::ExecuteAPI",
"Properties": {
"Service": "ECS",
"API": "DescribeInstances",
"Parameters": {
"Status": "Running"
}
},
"Outputs": {
"InstanceIds": {
"Type": "List",
"ValueSelector": "Instances.Instance[].InstanceId"
}
}
}
],
"Outputs": {
"InstanceIds": {
"Type": "String",
"Value": "{{ describeInstances.InstanceIds }}"
}
}
}
(Required) Output item name
The unique identifier of the output item in the template, such as InstanceIds in the example.
(Required) Type
The type of the output item, such as String
and List
.
(Required) ValueSelector
The attribute value returned after the template is executed. The value can be filtered by jQuery selectors specified by PropertySelector or ValueSelector.