Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-SMC-CreateAndVerifyInstance

Dernière mise à jour :Aug 11, 2026

Créez des instances de destination et vérifiez-les en exécutant des commandes dans Server Migration Center (SMC).

Nom du modèle

ACS-SMC-CreateAndVerifyInstance

Exécuter maintenant

Description du modèle

Ce modèle crée des instances de destination et exécute des commandes pour les vérifier dans Server Migration Center (SMC).

Type de modèle

Automatisé

Propriétaire

Alibaba Cloud

Paramètres d'entrée

Paramètre

Description

Type

Obligatoire

Valeur par défaut

Limite

zoneId

ID de la zone.

String

Oui

hostName

Nom d'hôte des instances de destination.

String

Oui

Expression régulière de validation de la chaîne : ^(?!.

imageId

ID de l'image pour la création des instances de destination.

String

Oui

instanceType

Type d'instance des instances de destination.

String

Oui

privateIp

Adresse IP privée des instances de destination.

String

Oui

regionId

ID de la région.

String

Non

{{ ACS::RegionId }}

systemDiskSize

Taille du disque système.

Number

Non

19

instancesCount

Nombre d'instances de destination à créer.

Number

Non

1

isDeleteInstance

Indique s'il faut supprimer les instances après la vérification.

Boolean

Non

True

commandType

Type de commande Cloud Assistant utilisé pour la vérification.

String

Non

RunShellScript

commandContent

Contenu de la commande Cloud Assistant utilisée pour la vérification.

String

Non

""

timeout

Délai d'expiration des commandes.

Number

Non

600

workingDir

Répertoire d'exécution des commandes.

String

Non

/root

passwordInherit

Indique s'il faut utiliser le mot de passe prédéfini dans l'image.

Boolean

Non

False

rateControl

Paramètres de contrôle du débit.

Json

Non

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

OOSAssumeRole

Rôle RAM endossé par OOS.

String

Non

""

Paramètres de sortie

Paramètre

Description

Type

instanceCheckResults

List

Stratégie d'autorisation requise pour exécuter le modèle

{
    "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"
        }
    ]
}

Références

Pour plus d'informations, consultez ACS-SMC-CreateAndVerifyInstance sur GitHub.

Contenu du modèle

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 }}'