Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS::Template

Última atualização: Jun 28, 2026

A ação ACS::Template incorpora um modelo em outro como modelo filho.

Descrição

A ação ACS::Template incorpora um modelo em outro como modelo filho. Use essa ação para modularizar um modelo complexo e dividi-lo em vários modelos filhos reutilizáveis. Você também pode definir operações comuns de O&M como modelos filhos. O CloudOps Orchestration Service (OOS) fornece ações de produtos de nuvem como modelos de operação para serviços comuns que você pode incorporar diretamente.

Sintaxe

Incorporar um modelo criado pelo nome do modelo

  • Formato geral (aplica-se a todos os modelos incorporáveis)

    Tasks:
    - Name: callChildTemplate1
      Action: ACS::Template
      Properties:
        TemplateName: child_template_name # Required. The name of the child template.
        TemplateVersion: v2 # Optional. By default, the latest version is used. 
        Parameters: # Optional. The parameters that are required for executing the child template. 
          ParameterName1: value1
    {
      "Tasks": [
        {
          "Name": "callChildTemplate1",
          "Action": "ACS::Template",
          "Properties": {
            "TemplateName": "child_template_name",
            "TemplateVersion": "v2",
            "Parameters": {
              "ParameterName1": "value1"
            }
          }
        }
      ]
    }                                
  • Formato simplificado (aplica-se apenas a ações de produtos de nuvem)

    Tasks:
    - Name: taskName # Required. The name of the task. Example: runMyInstances.
      Action: CloudProductActionName1 # Required. The name of the cloud product action. Example: ACS::ECS::RunInstances.
      Properties:
        ParameterName1: value1 # Optional. The parameter that is required for executing the cloud product action. Example: ImageId.
    {
      "Tasks": [
        {
          "Name": "taskName",
          "Action": "CloudProductActionName1",
          "Properties": {
            "ParameterName1": "parameterName1"
          }
        }
      ]
    }

Incorporar um novo modelo pelo conteúdo do modelo

Tasks:
- Name: callChildTemplate1
  Action: ACS::Template
  Properties:
    TemplateContent: 
      FormatVersion: OOS-2019-06-01 # Required. The version of the template. 
      Parameters: # Optional. The parameters that are required for executing the child template. 
      Tasks: # Optional. The action that is performed by the child template.
{
  "Tasks": [
    {
      "Name": "callChildTemplate1",
      "Action": "ACS::Template",
      "Properties": {
        "TemplateContent": {
          "FormatVersion": "OOS-2019-06-01",
          "Parameters": null,
          "Tasks": null
        }
      }
    }
  ]
}

Limites

A ação de incorporação tem os seguintes limites:

  • Um modelo não pode incorporar a si mesmo.

  • Não é permitido fazer incorporações circulares. Por exemplo, o modelo A incorpora B, B incorpora C e C incorpora A.

  • O número total de camadas de incorporação não pode exceder três.

  • Incorporar uma ação de produto de nuvem conta como uma camada de incorporação. Tarefas em loop não contam como incorporação.

Exemplos

Crie uma imagem para uma instância do Elastic Compute Service (ECS) ao incorporar a ação ACS::ECS::CreateImage

  • Formato geral (aplica-se a todos os modelos incorporáveis)

    ---
    FormatVersion: OOS-2019-06-01
    Description: Creates a custom image.
    Parameters:
      imageName:
        Description: The image name.
        Type: String
      instanceId:
        Description: The ID of the instance.
        Type: String
        AllowedPattern: i-[A-Za-z0-9]*
        MinLength: 1
        MaxLength: 30
      OOSAssumeRole:
        Type: String
        Description: oos assume this role to execution task
        Default: OOSServiceRole
    RamRole: '{{OOSAssumeRole}}'
    Tasks:
    - Name: createImage
      Action: ACS::Template
      Description: Creates a custom image.
      Properties:
        TemplateName: 'ACS::ECS::CreateImage'
        Parameters:
          ImageName: '{{ imageName }}'
          InstanceId: '{{ instanceId }}'
      Outputs:
        imageId:
          Type: String
          ValueSelector: ImageId
    Outputs:
      imageId:
        Type: String
        Value: '{{ createImage.imageId }}'        
    {
        "FormatVersion": "OOS-2019-06-01",
        "Description": "Creates a custom image.",
        "Parameters": {
            "imageName": {
                "Description": "The image name.",
                "Type": "String"
            },
            "instanceId": {
                "Description": "The ID of the instance.",
                "Type": "String",
                "AllowedPattern": "i-[A-Za-z0-9]*",
                "MinLength": 1,
                "MaxLength": 30
            },
            "OOSAssumeRole": {
                "Type": "String",
                "Description": "oos assume this role to execution task",
                "Default": "OOSServiceRole"
            }
        },
        "RamRole": "{{OOSAssumeRole}}",
        "Tasks": [
            {
                "Name": "createImage",
                "Action": "ACS::Template",
                "Description": "Creates a custom image.",
                "Properties": {
                    "TemplateName": "ACS::ECS::CreateImage",
                    "Parameters": {
                        "ImageName": "{{ imageName }}",
                        "InstanceId": "{{ instanceId }}"
                    }
                },
                "Outputs": {
                    "imageId": {
                        "Type": "String",
                        "ValueSelector": "ImageId"
                    }
                }
            }
        ],
        "Outputs": {
            "imageId": {
                "Type": "String",
                "Value": "{{ createImage.imageId }}"
            }
        }
    }        
  • Formato simplificado (aplica-se apenas a ações de produtos de nuvem)

    ---
    FormatVersion: OOS-2019-06-01
    Description: Creates a new Image from existing ECS Instance.
    Parameters:
      InstanceId:
        Description: the Instance Type for the new instances
        Type: String
      ImageName:
        Description:  name of the new image
        Type: String
      OOSAssumeRole:
        Type: String
        Description: oos assume this role to execution task
        Default: OOSServiceRole
    RamRole: "{{OOSAssumeRole}}"
    Tasks:
      - Name: createImage
        Action: ACS::ECS::CreateImage
        Properties:
          ImageName: "{{ ImageName }}"
          InstanceId: "{{ InstanceId }}"
        Outputs:
          ImageId:
            ValueSelector: ImageId
            Type: String
    Outputs:
      ImageId:
        Type: String
        Value: "{{ createImage.ImageId }}"
    {
      "FormatVersion": "OOS-2019-06-01",
      "Description": "Creates a new Image from existing ECS Instance.",
      "Parameters": {
        "InstanceId": {
          "Description": "the Instance Type for the new instances",
          "Type": "String"
        },
        "ImageName": {
          "Description": "name of the new image",
          "Type": "String"
        },
        "OOSAssumeRole": {
          "Type": "String",
          "Description": "oos assume this role to execution task",
          "Default": "OOSServiceRole"
        }
      },
      "RamRole": "{{OOSAssumeRole}}",
      "Tasks": [
        {
          "Name": "createImage",
          "Action": "ACS::ECS::CreateImage",
          "Properties": {
            "ImageName": "{{ ImageName }}",
            "InstanceId": "{{ InstanceId }}"
          },
          "Outputs": {
            "ImageId": {
              "ValueSelector": "ImageId",
              "Type": "String"
            }
          }
        }
      ],
      "Outputs": {
        "ImageId": {
          "Type": "String",
          "Value": "{{ createImage.ImageId }}"
        }
      }
    }

Consultar instâncias do ECS com a tag especificada com base no conteúdo do modelo

FormatVersion: OOS-2019-06-01
Description:
  name-en: DescribeInstances
   
Parameters:
  regionId:
    Label:
      en: The ID of region
       
    Type: String
    Default: '{{ ACS::RegionId }}'
Tasks:
  - Name: describeInstances_out
    Action: ACS::Template
    Description:
      en: Queries the ECS instances by specifying tag
       
    Properties:
      TemplateContent:
        FormatVersion: OOS-2019-06-01
        Description: ''
        Parameters:
          regionId:
            Label:
              en: The ID of region
               
            Type: String
            Default: '{{ ACS::RegionId }}'
        Tasks:
          - Name: describeInstances_1
            Action: ACS::Template
            Description:
              en: Queries the ECS instances by specifying tag
               
            Properties:
              TemplateContent:
                FormatVersion: OOS-2019-06-01
                Description: ''
                Parameters:
                  regionId:
                    Label:
                      en: The ID of region
                       
                    Type: String
                    Default: '{{ ACS::RegionId }}'
                Tasks:
                  - Name: describeInstances_2
                    Action: ACS::ExecuteAPI
                    Description:
                      en: Queries the ECS instances by specifying tag
                       
                    Properties:
                      Service: ECS
                      API: DescribeInstances
                      Parameters:
                        RegionId: '{{ regionId }}'
                    Outputs:
                      instanceIdss:
                        Type: List
                        ValueSelector: Instances.Instance[].InstanceId
                Outputs:
                  instanceId1:
                    Type: List
                    Value: '{{ describeInstances_2.instanceIdss}}'
              Parameters:
                regionId: '{{ regionId }}'
            Outputs:
              instanceId2:
                Type: List
                ValueSelector: .instanceId1
        Outputs:
          instanceId1:
            Type: List
            Value: '{{ describeInstances_1.instanceId2 }}'
      Parameters:
        regionId: '{{ regionId }}'
    Outputs:
      instanceId2:
        Type: List
        ValueSelector: .instanceId1
Outputs:
  instanceId4:
    Type: List
    Value: '{{ describeInstances_out.instanceId2}}'
{
  "FormatVersion": "OOS-2019-06-01",
  "Description": {
    "name-en": "DescribeInstances",
     
  },
  "Parameters": {
    "regionId": {
      "Label": {
        "en": "The ID of region",
         
      },
      "Type": "String",
      "Default": "{{ ACS::RegionId }}"
    }
  },
  "Tasks": [
    {
      "Name": "describeInstances_out",
      "Action": "ACS::Template",
      "Description": {
        "en": "Queries the ECS instances by specifying tag",
         
      },
      "Properties": {
        "TemplateContent": {
          "FormatVersion": "OOS-2019-06-01",
          "Description": "",
          "Parameters": {
            "regionId": {
              "Label": {
                "en": "The ID of region",
                 
              },
              "Type": "String",
              "Default": "{{ ACS::RegionId }}"
            }
          },
          "Tasks": [
            {
              "Name": "describeInstances_1",
              "Action": "ACS::Template",
              "Description": {
                "en": "Queries the ECS instances by specifying tag",
                 
              },
              "Properties": {
                "TemplateContent": {
                  "FormatVersion": "OOS-2019-06-01",
                  "Description": "",
                  "Parameters": {
                    "regionId": {
                      "Label": {
                        "en": "The ID of region",
                         
                      },
                      "Type": "String",
                      "Default": "{{ ACS::RegionId }}"
                    }
                  },
                  "Tasks": [
                    {
                      "Name": "describeInstances_2",
                      "Action": "ACS::ExecuteAPI",
                      "Description": {
                        "en": "Queries the ECS instances by specifying tag",
                         
                      },
                      "Properties": {
                        "Service": "ECS",
                        "API": "DescribeInstances",
                        "Parameters": {
                          "RegionId": "{{ regionId }}"
                        }
                      },
                      "Outputs": {
                        "instanceIdss": {
                          "Type": "List",
                          "ValueSelector": "Instances.Instance[].InstanceId"
                        }
                      }
                    }
                  ],
                  "Outputs": {
                    "instanceId1": {
                      "Type": "List",
                      "Value": "{{ describeInstances_2.instanceIdss}}"
                    }
                  }
                },
                "Parameters": {
                  "regionId": "{{ regionId }}"
                }
              },
              "Outputs": {
                "instanceId2": {
                  "Type": "List",
                  "ValueSelector": ".instanceId1"
                }
              }
            }
          ],
          "Outputs": {
            "instanceId1": {
              "Type": "List",
              "Value": "{{ describeInstances_1.instanceId2 }}"
            }
          }
        },
        "Parameters": {
          "regionId": "{{ regionId }}"
        }
      },
      "Outputs": {
        "instanceId2": {
          "Type": "List",
          "ValueSelector": ".instanceId1"
        }
      }
    }
  ],
  "Outputs": {
    "instanceId4": {
      "Type": "List",
      "Value": "{{ describeInstances_out.instanceId2}}"
    }
  }
}