All Products
Search
Document Center

General attributes

Last Updated: Sep 05, 2019

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:

  1. ---
  2. Tasks:
  3. - Name: task_name_1
  4. Action: 'Action'
  5. Description: describe the purpose of the task
  6. 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.
  7. 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.
  8. Properties:
  9. Service: ECS/RDS/RAM
  10. Risk: High/Normal
  11. API: DeleteInstance/CreateDBInstance/CreateRamRole
  12. Parameters:
  13. InstanceId: "i-XXX"
  14. Outputs:
  15. Output_parameter_name_1:
  16. Type: String/List
  17. 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
  1. ---
  2. FormatVersion: OOS-2019-06-01
  3. Description: delete instance
  4. Parameters:
  5. InstanceId:
  6. Description: the instance id that you will delete
  7. Type: String
  8. Tasks:
  9. - Name: deleteInstance
  10. Action: ACS::ExecuteAPI
  11. Description: delete instance with specified parameters
  12. Properties:
  13. Service: ECS
  14. API: DeleteInstance
  15. Risk: Normal
  16. Parameters:
  17. InstanceId: "{{ InstanceId }}"
  18. Outputs:
  19. RequestId:
  20. Type: String
  21. ValueSelector: RequestId
  22. Outputs:
  23. RequestId:
  24. Type: String
  25. Value: "{{ deleteInstance.RequestId }}"
  • JSON format
  1. {
  2. "FormatVersion": "OOS-2019-06-01",
  3. "Description": "delete instance",
  4. "Parameters": {
  5. "InstanceId": {
  6. "Description": "the instance id that you will delete",
  7. "Type": "String"
  8. }
  9. },
  10. "Tasks": [
  11. {
  12. "Name": "deleteInstance",
  13. "Action": "ACS::ExecuteAPI",
  14. "Description": "delete instance with specified parameters",
  15. "Properties": {
  16. "Service": "ECS",
  17. "API": "DeleteInstance",
  18. "Risk": "Normal",
  19. "Parameters": {
  20. "InstanceId": "{{ InstanceId }}"
  21. }
  22. },
  23. "Outputs": {
  24. "RequestId": {
  25. "Type": "String",
  26. "ValueSelector": "RequestId"
  27. }
  28. }
  29. }
  30. ],
  31. "Outputs": {
  32. "RequestId": {
  33. "Type": "String",
  34. "Value": "{{ deleteInstance.RequestId }}"
  35. }
  36. }
  37. }

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
  1. ---
  2. FormatVersion: OOS-2019-06-01
  3. Parameters:
  4. SourceImageId:
  5. Description: the image id of the source image to be updated
  6. Type: String
  7. InstanceType:
  8. Description: the Instance Type for the new instances
  9. Type: String
  10. SecurityGroupId:
  11. Description: the security group id for the new instances
  12. Type: String
  13. VSwitchId:
  14. Description: the virtual switch id for the new instances
  15. Type: String
  16. OOSAssumeRole:
  17. Type: String
  18. Description: oos assume this role to execution task
  19. Default: OOSServiceRole
  20. RamRole: "{{OOSAssumeRole}}"
  21. Tasks:
  22. - Name: runInstances
  23. Action: ACS::ECS::RunInstances
  24. Properties:
  25. ImageId: "{{ SourceImageId }}"
  26. InstanceType: "{{ InstanceType }}"
  27. SecurityGroupId: "{{ SecurityGroupId }}"
  28. VSwitchId: "{{ VSwitchId }}"
  29. Outputs:
  30. InstanceId:
  31. ValueSelector: InstanceIds[0]
  32. Type: String
  33. - Name: installCloudAssistant
  34. Action: ACS::ECS::InstallCloudAssistant
  35. OnError: deleteInstance
  36. Properties:
  37. InstanceId: "{{ runInstances.InstanceId }}"
  38. - Name: deleteInstance
  39. Action: ACS::ExecuteApi
  40. Properties:
  41. Service: ECS
  42. API: DeleteInstance
  43. Risk: Normal
  44. Parameters:
  45. InstanceId: "{{ runInstances.InstanceId }}"
  46. Force: true
  47. Outputs:
  48. InstanceId:
  49. Type: String
  50. Value: "{{ runInstances.InstanceId }}"
  • JSON format
  1. {
  2. "FormatVersion": "OOS-2019-06-01",
  3. "Parameters": {
  4. "SourceImageId": {
  5. "Description": "the image id of the source image to be updated",
  6. "Type": "String"
  7. },
  8. "InstanceType": {
  9. "Description": "the Instance Type for the new instances",
  10. "Type": "String"
  11. },
  12. "SecurityGroupId": {
  13. "Description": "the security group id for the new instances",
  14. "Type": "String"
  15. },
  16. "VSwitchId": {
  17. "Description": "the virtual switch id for the new instances",
  18. "Type": "String"
  19. },
  20. "OOSAssumeRole": {
  21. "Type": "String",
  22. "Description": "oos assume this role to execution task",
  23. "Default": "OOSServiceRole"
  24. }
  25. },
  26. "RamRole": "{{OOSAssumeRole}}",
  27. "Tasks": [
  28. {
  29. "Name": "runInstances",
  30. "Action": "ACS::ECS::RunInstances",
  31. "Properties": {
  32. "ImageId": "{{ SourceImageId }}",
  33. "InstanceType": "{{ InstanceType }}",
  34. "SecurityGroupId": "{{ SecurityGroupId }}",
  35. "VSwitchId": "{{ VSwitchId }}"
  36. },
  37. "Outputs": {
  38. "InstanceId": {
  39. "ValueSelector": "InstanceIds[0]",
  40. "Type": "String"
  41. }
  42. }
  43. },
  44. {
  45. "Name": "installCloudAssistant",
  46. "Action": "ACS::ECS::InstallCloudAssistant",
  47. "OnError": "deleteInstance",
  48. "Properties": {
  49. "InstanceId": "{{ runInstances.InstanceId }}"
  50. }
  51. },
  52. {
  53. "Name": "deleteInstance",
  54. "Action": "ACS::ExecuteApi",
  55. "Properties": {
  56. "Service": "ECS",
  57. "API": "DeleteInstance",
  58. "Risk": "Normal",
  59. "Parameters": {
  60. "InstanceId": "{{ runInstances.InstanceId }}",
  61. "Force": true
  62. }
  63. }
  64. }
  65. ],
  66. "Outputs": {
  67. "InstanceId": {
  68. "Type": "String",
  69. "Value": "{{ runInstances.InstanceId }}"
  70. }
  71. }
  72. }

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
  1. ---
  2. FormatVersion: OOS-2019-06-01
  3. Tasks:
  4. - Name: describeInstances
  5. Action: ACS::ExecuteAPI
  6. Properties:
  7. Service: ECS
  8. API: DescribeInstances
  9. Parameters:
  10. Status: "Running"
  11. Outputs:
  12. InstanceIds:
  13. Type: List
  14. ValueSelector: Instances.Instance[].InstanceId
  15. Outputs:
  16. InstanceIds:
  17. Type: String
  18. Value: "{{ describeInstances.InstanceIds }}"
  • JSON format
  1. {
  2. "FormatVersion": "OOS-2019-06-01",
  3. "Tasks": [
  4. {
  5. "Name": "describeInstances",
  6. "Action": "ACS::ExecuteAPI",
  7. "Properties": {
  8. "Service": "ECS",
  9. "API": "DescribeInstances",
  10. "Parameters": {
  11. "Status": "Running"
  12. }
  13. },
  14. "Outputs": {
  15. "InstanceIds": {
  16. "Type": "List",
  17. "ValueSelector": "Instances.Instance[].InstanceId"
  18. }
  19. }
  20. }
  21. ],
  22. "Outputs": {
  23. "InstanceIds": {
  24. "Type": "String",
  25. "Value": "{{ describeInstances.InstanceIds }}"
  26. }
  27. }
  28. }

(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.