Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS-SMC-CreateAndVerifyInstance

Última atualização: Jun 28, 2026

Crie instâncias de destino e verifique-as por meio da execução de comandos no Server Migration Center (SMC).

Nome do modelo

ACS-SMC-CreateAndVerifyInstance

Executar agora

Descrição do modelo

Cria instâncias de destino e executa comandos para verificá-las no Server Migration Center (SMC).

Tipo de modelo

Automatizado

Proprietário

Alibaba Cloud

Parâmetros de entrada

Parâmetro

Descrição

Tipo

Obrigatório

Valor padrão

Limite

zoneId

ID da zona.

String

Sim

hostName

Nome de host das instâncias de destino.

String

Sim

Expressão regular para validação de string: ^(?!.

imageId

ID da imagem para criar as instâncias de destino.

String

Sim

instanceType

Tipo das instâncias de destino.

String

Sim

privateIp

Endereço IP privado das instâncias de destino.

String

Sim

regionId

ID da região.

String

Não

{{ ACS::RegionId }}

systemDiskSize

Tamanho do disco do sistema.

Number

Não

19

instancesCount

Quantidade de instâncias de destino a criar.

Number

Não

1

isDeleteInstance

Indica se as instâncias serão excluídas após a verificação.

Boolean

Não

True

commandType

Tipo de comando do Cloud Assistant usado na verificação.

String

Não

RunShellScript

commandContent

Conteúdo do comando do Cloud Assistant usado na verificação.

String

Não

""

timeout

Tempo limite de execução dos comandos.

Number

Não

600

workingDir

Diretório de execução dos comandos.

String

Não

/root

passwordInherit

Indica se a senha predefinida na imagem será utilizada.

Boolean

Não

False

rateControl

Configurações de controle de taxa.

Json

Não

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

Função RAM assumida pelo OOS.

String

Não

""

Parâmetros de saída

Parâmetro

Descrição

Tipo

instanceCheckResults

List

Política de permissões necessária para executar o modelo

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DeleteInstance",
                "ecs:DeleteSecurityGroup",
                "ecs:DescribeCloudAssistantStatus",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:InstallCloudAssistant",
                "ecs:RebootInstance",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ros:CreateStack",
                "ros:DeleteStack",
                "ros:GetStack"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "vpc:DeleteVSwitch",
                "vpc:DeleteVpc",
                "vpc:DescribeVSwitches",
                "vpc:DescribeVpcs"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Referências

Para mais informações, consulte ACS-SMC-CreateAndVerifyInstance no GitHub.

Conteúdo do modelo

FormatVersion: OOS-2019-06-01
Description:
  en: Create and verify instance by commands
  name-en: ACS-SMC-CreateAndVerifyInstance
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  zoneId:
    Label:
      en: ZoneId
    Description:
      en: The target zone id of VSwitch to create
    AssociationProperty: 'ALIYUN::ECS::Instance::ZoneId'
    Type: String
    AssociationPropertyMetadata:
      RegionId: regionId
  hostName:
    Label:
      en: HostName
    Type: String
    AllowedPattern: '^(?!\.|\-)(?!.*\.\.|.*\-\-)(?!.*_).*(?<!\.|\-)$'
    MinLength: 2
  imageId:
    Label:
      en: ImageId
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
    AssociationPropertyMetadata:
      RegionId: regionId
  instanceType:
    Label:
      en: InstanceType
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
  privateIp:
    Label:
      en: PrivateIp
    Type: String
  systemDiskSize:
    Label:
      en: SystemDiskSize
    Type: Number
    Default: 19
    MinValue: 19
    MaxValue: 500
  instancesCount:
    Label:
      en: InstancesCount
    Type: Number
    Default: 1
    MinValue: 1
    MaxValue: 999
  isDeleteInstance:
    Label:
      en: IsDeleteInstance
    Type: Boolean
    Default: true
  commandType:
    Label:
      en: CommandType
    Type: String
    AllowedValues:
      - RunBatScript
      - RunPowerShellScript
      - RunShellScript
    Default: RunShellScript
  commandContent:
    Label:
      en: CommandContent
    Type: String
    AssociationProperty: Code
    Default: ''
  timeout:
    Label:
      en: Timeout
    Type: Number
    Default: 600
  workingDir:
    Label:
      en: WorkingDir
    Type: String
    Default: /root
  passwordInherit:
    Description:
      en:  To use the PasswordInherit parameter, the Password parameter must be empty and you must make sure that the selected image has a password configured(default:false)
    Label:
      en: IsUsePasswordInherit
    Type: Boolean
    Default: false
  rateControl:
    Label:
      en: RateControl
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: describeImages
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Query the image ostype by image id
    Properties:
      Service: ECS
      API: DescribeImages
      Parameters:
        RegionId: '{{ regionId }}'
        ImageId: '{{ imageId }}'
    Outputs:
      osType:
        ValueSelector: 'Images.Image[0].OSType'
        Type: String
  - Name: converConstant
    Action: 'ACS::ECS::SMCConversionConstantByJqScript'
    Description:
      en: Automatically convert to available CidrBlock according to PrivateIp
    Properties:
      parameter: '{{ privateIp }}'
      jqScript:
        - '.[0] | split(".") as $item | $item | if .[0]=="10" then "10.0.0.0/8" elif .[0]=="172" then "172.16.0.0/12" elif .[0]=="192" then "192.168.0.0/16" else "" end'
        - '.[0] | split(".") as $item | $item | if .[0]=="10" then "10."+.[1]+".0.0/16" elif .[0]=="172" then "172."+.[1]+"."+.[2]+".0/24" elif .[0]=="192" then "192.168."+.[2]+".0/24" else "" end'
    Outputs:
      vswCidrBlock:
        Type: String
        ValueSelector: secondValue
      vpcCidrBlock:
        Type: String
        ValueSelector: firstValue
  - Name: createStack
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Create a resource stack
    Properties:
      Service: ROS
      API: CreateStack
      Parameters:
        RegionId: '{{ regionId  }}'
        StackName: 'OOS-{{ACS::ExecutionId}}'
        TimeoutInMinutes: 10
        DisableRollback: false
        Parameters:
          - ParameterKey: hostName
            ParameterValue: '{{ hostName }}'
          - ParameterKey: privateIp
            ParameterValue: '{{ privateIp }}'
          - ParameterKey: instanceType
            ParameterValue: '{{ instanceType }}'
          - ParameterKey: zoneId
            ParameterValue: '{{ zoneId }}'
          - ParameterKey: regionId
            ParameterValue: '{{ regionId  }}'
          - ParameterKey: imageId
            ParameterValue: '{{imageId}}'
          - ParameterKey: executionId
            ParameterValue: '{{ ACS::ExecutionId }}'
          - ParameterKey: instancesCount
            ParameterValue: '{{ instancesCount }}'
          - ParameterKey: systemDiskSize
            ParameterValue: '{{ systemDiskSize }}'
          - ParameterKey: passwordInherit
            ParameterValue: '{{ passwordInherit }}'
        TemplateBody:
          'Fn::If':
            - 'Fn::Equals':
                - windows
                - '{{ describeImages.osType }}'
            - |
              {
                "Description": "Create VPC ECS instance",
                "Parameters": {
                  "imageId": {
                    "Type": "String"
                  },
                  "hostName": {
                    "Type": "String"
                  },
                  "privateIp": {
                    "Type": "String"
                  },
                  "instanceType": {
                    "Type": "String"
                  },
                  "executionId": {
                    "Type": "String"
                  },
                  "instancesCount": {
                    "Type": "String"
                  },
                  "zoneId": {
                    "Type": "String"
                  },
                  "regionId": {
                    "Type": "String"
                  },
                  "systemDiskSize": {
                    "Type": "Number"
                  },
                  "passwordInherit": {
                    "Type": "Boolean"
                  },
                  "resourcePrefix": {
                    "Type": "String",
                    "Default": "oos-generated"
                  }
                },
                "Conditions":{
                    "CreateSystemDiskSize":{
                        "Fn::Equals":[
                            19,
                            {
                                "Ref":"systemDiskSize"
                            }
                        ]
                    }
                },
                "ROSTemplateFormatVersion": "2015-09-01",
                "Outputs": {
                  "ecs_instance_id": {
                    "Value": {
                      "Fn::GetAtt": [
                        "ecs",
                        "InstanceIds"
                      ]
                    }
                  }
                },
                "Resources": {
                  "vswitch": {
                    "Type": "ALIYUN::ECS::VSwitch",
                    "Properties": {
                      "VpcId": {
                        "Ref": "vpc"
                      },
                      "Description": {
                        "Fn::Join": [
                          " ",
                          [
                            "OOS execution id is",
                            {
                              "Ref": "executionId"
                            }
                          ]
                        ]
                      },
                      "ZoneId": {
                        "Ref": "zoneId"
                      },
                      "CidrBlock": "{{ converConstant.vswCidrBlock }}"
                    }
                  },
                  "sg": {
                    "Type": "ALIYUN::ECS::SecurityGroup",
                    "Properties": {
                      "Tags": [
                        {
                          "Key": "oos-generated",
                          "Value": {
                            "Ref": "executionId"
                          }
                        },
                        {
                          "Key": "region",
                          "Value": {
                            "Ref": "regionId"
                          }
                        }
                      ],
                      "VpcId": {
                        "Ref": "vpc"
                      },
                      "SecurityGroupName": {
                        "Fn::Join": [
                          "-",
                          [
                            {
                              "Ref": "resourcePrefix"
                            },
                            "sg"
                          ]
                        ]
                      },
                      "SecurityGroupEgress": [
                        {
                          "PortRange": "-1/-1",
                          "Priority": 1,
                          "IpProtocol": "all",
                          "DestCidrIp": "0.0.0.0/0",
                          "NicType": "intranet"
                        }
                      ],
                      "SecurityGroupIngress": [
                        {
                          "PortRange": "3389/3389",
                          "Priority": 1,
                          "IpProtocol": "tcp",
                          "SourceCidrIp": "0.0.0.0/0",
                          "NicType": "intranet"
                        }
                      ]
                    }
                  },
                  "vpc": {
                    "Type": "ALIYUN::ECS::VPC",
                    "Properties": {
                      "CidrBlock": "{{ converConstant.vpcCidrBlock }}",
                      "Description": {
                        "Fn::Join": [
                          " ",
                          [
                            "OOS execution id is",
                            {
                              "Ref": "executionId"
                            }
                          ]
                        ]
                      },
                      "VpcName": {
                        "Fn::Join": [
                          "-",
                          [
                            {
                              "Ref": "resourcePrefix"
                            },
                            "vpc"
                          ]
                        ]
                      }
                    }
                  },
                  "ecs": {
                    "Type": "ALIYUN::ECS::InstanceGroup",
                    "Properties": {
                      "ImageId": {
                        "Ref": "imageId"
                      },
                      "HostName": {
                        "Ref": "hostName"
                      },
                      "PrivateIpAddress": {
                        "Ref": "privateIp"
                      },
                      "SecurityGroupId": {
                        "Ref": "sg"
                      },
                      "VpcId": {
                        "Ref": "vpc"
                      },
                      "VSwitchId": {
                        "Ref": "vswitch"
                      },
                      "InstanceType": {
                        "Ref": "instanceType"
                      },
                      "PasswordInherit": {
                        "Ref": "passwordInherit"
                      },
                      "SystemDiskSize": {
                        "Fn::If": [
                          "CreateSystemDiskSize",
                            {
                              "Ref": "ALIYUN::NoValue"
                            },
                            {
                              "Ref": "systemDiskSize"
                            }
                        ]
                      },
                      "MinAmount": {
                        "Ref": "instancesCount"
                      },
                      "MaxAmount": {
                        "Ref": "instancesCount"
                      },
                      "Tags": [
                        {
                          "Key": "oos-generated",
                          "Value": {
                            "Ref": "executionId"
                          }
                        },
                        {
                          "Key": "region",
                          "Value": {
                            "Ref": "regionId"
                          }
                        }
                      ]
                    }
                  }
                },
                "Metadata": {
                  "ALIYUN::ROS::Interface": {
                    "TemplateTags": [
                      "acs:integrate:oos:smc_create_and_verify_instance"
                    ]
                  }
                }
              }
            - |
              {
                "Description": "Create VPC ECS instance",
                "Parameters": {
                  "imageId": {
                    "Type": "String"
                  },
                  "hostName": {
                    "Type": "String"
                  },
                  "privateIp": {
                    "Type": "String"
                  },
                  "instanceType": {
                    "Type": "String"
                  },
                  "passwordInherit": {
                    "Type": "Boolean"
                  },
                  "executionId": {
                    "Type": "String"
                  },
                  "instancesCount": {
                    "Type": "String"
                  },
                  "zoneId": {
                    "Type": "String"
                  },
                  "regionId": {
                    "Type": "String"
                  },
                  "systemDiskSize": {
                    "Type": "Number"
                  },
                  "resourcePrefix": {
                    "Type": "String",
                    "Default": "oos-generated"
                  }
                },
                "Conditions":{
                    "CreateSystemDiskSize":{
                        "Fn::Equals":[
                            19,
                            {
                                "Ref":"systemDiskSize"
                            }
                        ]
                    }
                },
                "ROSTemplateFormatVersion": "2015-09-01",
                "Outputs": {
                  "ecs_instance_id": {
                    "Value": {
                      "Fn::GetAtt": [
                        "ecs",
                        "InstanceIds"
                      ]
                    }
                  }
                },
                "Resources": {
                  "vswitch": {
                    "Type": "ALIYUN::ECS::VSwitch",
                    "Properties": {
                      "VpcId": {
                        "Ref": "vpc"
                      },
                      "Description": {
                        "Fn::Join": [
                          " ",
                          [
                            "OOS execution id is",
                            {
                              "Ref": "executionId"
                            }
                          ]
                        ]
                      },
                      "ZoneId": {
                        "Ref": "zoneId"
                      },
                      "CidrBlock": "{{ converConstant.vswCidrBlock }}"
                    }
                  },
                  "sg": {
                    "Type": "ALIYUN::ECS::SecurityGroup",
                    "Properties": {
                      "Tags": [
                        {
                          "Key": "oos-generated",
                          "Value": {
                            "Ref": "executionId"
                          }
                        },
                        {
                          "Key": "region",
                          "Value": {
                            "Ref": "regionId"
                          }
                        }
                      ],
                      "VpcId": {
                        "Ref": "vpc"
                      },
                      "SecurityGroupName": {
                        "Fn::Join": [
                          "-",
                          [
                            {
                              "Ref": "resourcePrefix"
                            },
                            "sg"
                          ]
                        ]
                      },
                      "SecurityGroupEgress": [
                        {
                          "PortRange": "-1/-1",
                          "Priority": 1,
                          "IpProtocol": "all",
                          "DestCidrIp": "0.0.0.0/0",
                          "NicType": "intranet"
                        }
                      ],
                      "SecurityGroupIngress": [
                        {
                          "PortRange": "22/22",
                          "Priority": 1,
                          "IpProtocol": "tcp",
                          "SourceCidrIp": "0.0.0.0/0",
                          "NicType": "intranet"
                        }
                      ]
                    }
                  },
                  "vpc": {
                    "Type": "ALIYUN::ECS::VPC",
                    "Properties": {
                      "CidrBlock": "{{ converConstant.vpcCidrBlock }}",
                      "Description": {
                        "Fn::Join": [
                          " ",
                          [
                            "OOS execution id is",
                            {
                              "Ref": "executionId"
                            }
                          ]
                        ]
                      },
                      "VpcName": {
                        "Fn::Join": [
                          "-",
                          [
                            {
                              "Ref": "resourcePrefix"
                            },
                            "vpc"
                          ]
                        ]
                      }
                    }
                  },
                  "ecs": {
                    "Type": "ALIYUN::ECS::InstanceGroup",
                    "Properties": {
                      "ImageId": {
                        "Ref": "imageId"
                      },
                      "HostName": {
                        "Ref": "hostName"
                      },
                      "PrivateIpAddress": {
                        "Ref": "privateIp"
                      },
                      "SecurityGroupId": {
                        "Ref": "sg"
                      },
                      "VpcId": {
                        "Ref": "vpc"
                      },
                      "VSwitchId": {
                        "Ref": "vswitch"
                      },
                      "InstanceType": {
                        "Ref": "instanceType"
                      },
                      "PasswordInherit": {
                        "Ref": "passwordInherit"
                      },
                      "SystemDiskSize": {
                        "Fn::If": [
                          "CreateSystemDiskSize",
                            {
                              "Ref": "ALIYUN::NoValue"
                            },
                            {
                              "Ref": "systemDiskSize"
                            }
                        ]
                      },
                      "MinAmount": {
                        "Ref": "instancesCount"
                      },
                      "MaxAmount": {
                        "Ref": "instancesCount"
                      },
                      "Tags": [
                        {
                          "Key": "oos-generated",
                          "Value": {
                            "Ref": "executionId"
                          }
                        },
                        {
                          "Key": "region",
                          "Value": {
                            "Ref": "regionId"
                          }
                        }
                      ]
                    }
                  }
                },
                "Metadata": {
                  "ALIYUN::ROS::Interface": {
                    "TemplateTags": [
                      "acs:integrate:oos:smc_create_and_verify_instance"
                    ]
                  }
                }
              }
    Outputs:
      StackId:
        Type: String
        ValueSelector: StackId
  - Name: untilStackReady
    Action: 'ACS::WaitFor'
    Description:
      en: Wait for the stack status CREATE_COMPLETE
    OnSuccess: doInstanceCheck
    OnError: queryStackStatusReason
    Properties:
      Service: ROS
      API: GetStack
      Parameters:
        RegionId: '{{ regionId  }}'
        StackId: '{{createStack.StackId}}'
      DesiredValues:
        - CREATE_COMPLETE
      StopRetryValues:
        - CREATE_FAILED
        - CHECK_FAILED
        - ROLLBACK_FAILED
        - ROLLBACK_COMPLETE
        - CREATE_ROLLBACK_COMPLETE
      PropertySelector: Status
    Outputs:
      instanceIds:
        Type: String
        ValueSelector: 'Outputs[0].OutputValue'
  - Name: doInstanceCheck
    Action: 'ACS::ECS::SMCVerifyInstanceByRunCommand'
    OnSuccess: 'ACS::END'
    OnError: deleteStack
    Description:
      en: Execute cloud assistant command to check Instance
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      isDeleteInstance: '{{ isDeleteInstance }}'
      commandContent: '{{ commandContent }}'
      commandType: '{{ commandType }}'
      workingDir: '{{ workingDir }}'
      timeout: '{{ timeout }}'
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ untilStackReady.instanceIds }}'
      Outputs:
        commandOutputs:
          AggregateType: 'Fn::ListJoin'
          AggregateField: commandOutput
  - Name: queryStackStatusReason
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Query the reson of failed created stack
    OnError: deleteStack
    OnSuccess: deleteStack
    Properties:
      Service: ROS
      API: GetStack
      Parameters:
        RegionId: '{{ regionId  }}'
        StackId: '{{ createStack.StackId }}'
    Outputs:
      statusReason:
        Type: String
        ValueSelector: StatusReason
  - Name: deleteStack
    Description:
      en: Delete the stack
    OnSuccess: 'ACS::END'
    Action: 'ACS::ExecuteApi'
    Properties:
      Service: ROS
      API: DeleteStack
      Parameters:
        RegionId: '{{ regionId }}'
        StackId: '{{createStack.StackId}}'
Outputs:
  instanceCheckResults:
    Type: List
    Value: '{{ doInstanceCheck.commandOutputs }}'