Customize templates with the AI Template Assistant

Updated at:

To simplify template authoring, you can use the AI Template Assistant in Resource Orchestration Service (ROS) to generate ROS templates based on natural language descriptions of the cloud resource architecture you need.

Procedure

  1. Log on to the Resource Orchestration Service console.

  2. In the left-side navigation pane, choose Templates > My Templates.

  3. On the My Templates page, click Create Template.

  4. On the Create Template page, select a Template Type and choose AI Assistant as the creation method.

    Note

    ROS templates and Terraform templates are supported.

  5. Create a template. This example shows how to create an ECS instance.

    Provide the following key information:

    • Create an ECS instance that runs CentOS 7.

    • The ECS instance requires a custom instance password.

    • Use the instance ID of the ECS instance as an output.

    ROS

    For example, enter a description like the following into the AI assistant: "Create an ECS instance that runs the CentOS 7 operating system. To make the template reusable, set template parameters for values like the instance password. To view resource properties after creation, set the instance ID as a template output."

    1. Select ROS Template and click Create with AI Assistant. Then, describe the infrastructure you want to create.

    2. Click Create Template to start generating the template.

      During template generation, a sidebar appears and displays task logs, intermediate templates, and a history of template modifications.

      Note

      If you have any questions, contact us for support.

      • ROS template static fix: Uses the ROS resource schema and other definitions to statically correct errors in the template.

      • ROS template dynamic fix: Calls the ROS API to analyze the template and modifies it based on error messages. The dynamic fix feature automatically corrects template errors, with a maximum of 5 retries. After a successful fix, the corrected YAML template content, including definitions for parameters such as ROSTemplateFormatVersion and Parameters, is displayed in a dialog box. After you confirm the changes, click Apply to write the corrected template to the editor, or click Close to cancel the operation.

    3. After generation is complete, click Apply to render the template in the Template Content text box. Then, click Save Template to finish creating the template.

    Terraform

    The page has three input boxes. The first is for describing the environment or resources to generate (for example, Create an ECS instance that runs the CentOS 7 operating system). The second is for setting template parameters to improve reusability (for example, A custom instance password is required). The third is for setting template outputs (for example, Use the instance ID of the ECS instance as an output).

    1. Select Terraform Template and click Create with AI Assistant. Then, describe the infrastructure that you want to create.

    2. Click Create Template to start generating the template.

      During template generation, a sidebar appears and displays task logs, intermediate templates, and a history of template modifications.

      Terraform template dynamic fix: Calls the ROS API to analyze the template and modify it based on error messages.

      The following is an example of the corrected HCL template:

      data "alicloud_instance_types" "default" {
        instance_type_family = "ecs.g6"
        availability_zone    = local.zone_id
      }
      data "alicloud_images" "centos_7" {
        name_regex  = "^centos_7_.*"
        most_recent = true
        owners = ["system"]
      }
      resource "alicloud_vpc" "default" {
        cidr_block = "172.16.0.0/16"
        name       = "terraform-vpc"
      }
      resource "alicloud_vswitch" "default" {
        vpc_id       = alicloud_vpc.default.id
        cidr_block   = "172.16.1.0/24"
        zone_id      = local.zone_id
        vswitch_name = "terraform-vswitch"
      }

    1. After generation is complete, click Apply to render the template in the Template Content text box. Then, click Save Template to finish creating the template.

      Note

      If you have any questions, contact us for support.

Related documentation

Create a resource stack from the template you created. For more information, see Create a resource stack from a template.