All Products
Search
Document Center

Create a template

Last Updated: Sep 05, 2019

After creating an Operation Orchestration Service (OOS)-trusted role and granting the required permissions to the role, you can create a template.

This topic describes how to create a simple template for obtaining the IDs of Elastic Compute Service (ECS) instances in a specified status, such as Running or Stopped, under the current account. The template uses the OOSServiceRole role to call the DescribeInstances operation and automatically goes through the records to search for ECS instances in the specified status. If no more than 1,000 ECS instances are in the specified status, the IDs of all these ECS instances are returned. If more than 1,000 ECS instances are in the specified status, the IDs of the first 1,000 ECS instances in the specified status are returned. For more information, see Restrictions.

Procedure

  1. Log on to the ECS console. Choose Maintenance & Monitoring > Operation Orchestration Service in the left-side navigation pane.

  2. Click the Custom Templates tab, and then click Create Template.

  3. In the Basic Information section, set template parameters.

    oos
  4. Set Template Name to DescribeInstances in this example.
  5. In the template details section, select the YAML format and insert the following code.

    Note: You can modify this template to add multiple tasks and call any API operation, as long as you have granted sufficient permissions the OOSServiceRole role.

    1. ---
    2. Description: DescribeInstances
    3. FormatVersion: OOS-2019-06-01
    4. Outputs:
    5. InstanceIds:
    6. Type: List
    7. Value: "{{ describeInstances.InstanceIds }}"
    8. Parameters:
    9. Status:
    10. Description: Running or Stopped
    11. Type: String
    12. Tasks:
    13. - Name: describeInstances
    14. Action: ACS::ExecuteAPI
    15. Properties:
    16. Service: ECS
    17. API: DescribeInstances
    18. Parameters:
    19. Status: "{{ Status }}"
    20. Outputs:
    21. InstanceIds:
    22. Type: List
    23. ValueSelector: .Instances.Instance[].InstanceId
  6. Click Create Template.