すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-CloneInstancesAcrossRegion

最終更新日:Jun 23, 2026

テンプレート名

ACS-ECS-CloneInstancesAcrossRegion:リージョン間で ECS インスタンスをクローンします。

[Run Now]

テンプレートの説明

リージョン間で ECS インスタンスをクローンします。

テンプレートタイプ

オートメーション

所有者

Alibaba Cloud

入力パラメーター

パラメーター名

説明

タイプ

必須

デフォルト値

制約

instanceIds

ECS インスタンス ID。

リスト

はい

regionId

ソースリージョン ID。

文字列

はい

最大長: 30

最小長: 1

targetRegionId

ターゲットリージョン ID。

文字列

はい

最大長: 30

最小長: 1

targetZoneId

ターゲットゾーン ID。

文字列

はい

最大長: 30

最小長: 1

targetInstanceType

インスタンスタイプ。

文字列

はい

文字列検証用の正規表現: ecs.[A-Za-z0-9.-]*

最大長: 30

最小長: 1

targetSecurityGroupId

セキュリティグループ ID。

文字列

はい

文字列検証用の正規表現: sg-[A-Za-z0-9]*

最大長: 30

最小長: 1

targetVSwitchId

vSwitch ID。

文字列

はい

文字列検証用の正規表現: vsw-[A-Za-z0-9]*

最大長: 30

最小長: 1

OOSAssumeRole

OOS が引き受ける RAM ロール。

文字列

いいえ

""

出力パラメーター

パラメーター名

説明

タイプ

instanceIds

リスト

このテンプレートの実行に必要な権限

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CopyImage",
                "ecs:CreateImage",
                "ecs:DescribeDisks",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:RunInstances"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳細

ACS-ECS-CloneInstancesAcrossRegion の詳細

テンプレートの内容

FormatVersion: OOS-2019-06-01
Description:
  en: Cross Region copy and run ECS instance by InstanceIds
  zh-cn: Clones ECS instances across regions.
  title: ACS-ECS-CloneInstancesAcrossRegion
  name-en: ACS-ECS-CloneInstancesAcrossRegion
  name-zh-cn: Clones ECS instances across regions.
  categories:
    - cross_region
Parameters:
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: The IDs of the ECS instances.
    Type: List
  regionId:
    Label:
      en: RegionId
      zh-cn: The ID of the source region.
    Type: String
    MinLength: 1
    MaxLength: 30
  targetRegionId:
    Label:
      en: TargetRegionId
      zh-cn: The ID of the destination region.
    Type: String
    MinLength: 1
    MaxLength: 30
  targetZoneId:
    Label:
      en: TargetZoneId
      zh-cn: The ID of the destination zone.
    Type: String
    MinLength: 1
    MaxLength: 30
  targetInstanceType:
    Label:
      en: TargetInstanceType
      zh-cn: The instance type.
    Type: String
    AllowedPattern: 'ecs\.[A-Za-z0-9\.\-]*'
    MinLength: 1
    MaxLength: 30
  targetSecurityGroupId:
    Label:
      en: TargetSecurityGroupId
      zh-cn: The security group ID.
    Type: String
    AllowedPattern: 'sg-[A-Za-z0-9]*'
    MinLength: 1
    MaxLength: 30
  targetVSwitchId:
    Label:
      en: TargetVSwitchId
      zh-cn: The vSwitch ID.
    Type: String
    AllowedPattern: 'vsw-[A-Za-z0-9]*'
    MinLength: 1
    MaxLength: 30
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes.
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: queryDisks
    Action: ACS::ExecuteAPI
    Description:
      en: Views disk info of the ECS instance
      zh-cn: Views the disk information of the instance.
    Properties:
      Service: ECS
      API: DescribeDisks
      Parameters:
        RegionId: '{{ regionId }}'
        InstanceId: '{{ ACS::TaskLoopItem }}'
    Outputs:
      instanceDataDisks:
        Type: Json
        ValueSelector: '.Disks.Disk|map( select(.Type == "data" )|{"Category":(.Category),"Device": (.Device),"Size":(.Size),"DiskName":(.DiskName),"PerformanceLevel":(.PerformanceLevel)})'
      instanceSystemDisk:
        Type: Json
        ValueSelector: '.Disks.Disk|map( select(.Type == "system" )|{"Category":(.Category),"Device": (.Device),"Size":(.Size),"DiskName":(.DiskName),"PerformanceLevel":(.PerformanceLevel)})[]'
    Loop:
      Items: '{{ instanceIds }}'
      Outputs:
        dataDisks:
          AggregateType: 'Fn::ListJoin'
          AggregateField: instanceDataDisks
        systemDisks:
          AggregateType: 'Fn::ListJoin'
          AggregateField: instanceSystemDisk
  - Name: createImage
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Create Image
      zh-cn: Creates an image.
    Properties:
      Service: ECS
      API: CreateImage
      Parameters:
        RegionId: '{{ regionId }}'
        ImageName: 'img-{{ ACS::TaskLoopItem }}-{{ACS::ExecutionId}}'
        InstanceId: '{{ ACS::TaskLoopItem }}'
        DetectionStrategy: Standard
    Loop:
      Items: '{{ instanceIds }}'
      Outputs:
        ImageIds:
          AggregateType: 'Fn::ListJoin'
          AggregateField: ImageId
    Outputs:
      ImageId:
        ValueSelector: ImageId
        Type: String
  - Name: untilCreateImageReady
    Action: 'ACS::WaitFor'
    Description:
      en: Wait For created images available
      zh-cn: Waits for the image to be created.
    Properties:
      Service: ECS
      API: DescribeImages
      Parameters:
        RegionId: '{{ regionId }}'
        ImageId: '{{ ACS::TaskLoopItem }}'
      DesiredValues:
        - Available
      PropertySelector: 'Images.Image[].Status'
    Loop:
      Items: '{{ createImage.ImageIds }}'
    Retries: 57
  - Name: copyImage
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Copy image
      zh-cn: Copies the image.
    Properties:
      Service: ECS
      API: CopyImage
      Parameters:
        RegionId: '{{ regionId }}'
        ImageId: '{{ ACS::TaskLoopItem }}'
        DestinationRegionId: '{{ targetRegionId }}'
    Loop:
      Items: '{{ createImage.ImageIds }}'
      Outputs:
        ImageIds:
          AggregateType: 'Fn::ListJoin'
          AggregateField: ImageId
    Outputs:
      ImageId:
        ValueSelector: ImageId
        Type: String
  - Name: untilCopyImageReady
    Action: 'ACS::WaitFor'
    Description:
      en: Wait for copied images available
      zh-cn: Waits for the image to be copied.
    Properties:
      Service: ECS
      API: DescribeImages
      Parameters:
        RegionId: '{{ targetRegionId }}'
        ImageId: '{{ ACS::TaskLoopItem }}'
      DesiredValues:
        - Available
      PropertySelector: 'Images.Image[].Status'
    Loop:
      Items: '{{ copyImage.ImageIds }}'
  - Name: runInstances
    Action: 'ACS::ExecuteAPI'
    Description:
      en: run instances
      zh-cn: Creates an instance.
    Properties:
      Service: ECS
      API: RunInstances
      Parameters:
        RegionId: '{{ targetRegionId }}'
        ZoneId: '{{ targetZoneId }}'
        ImageId:
          'Fn::Select':
              - '{{ ACS::TaskLoopItem }}'
              - '{{ copyImage.ImageIds }}'
        DataDisks:
          'Fn::Select':
            - '{{ ACS::TaskLoopItem }}'
            - '{{queryDisks.dataDisks}}'
        SystemDiskCategory:
          'Fn::Select':
            - Category
            - 'Fn::Select':
                - '{{ ACS::TaskLoopItem }}'
                - '{{ queryDisks.systemDisks }}'
        SystemDiskSize:
          'Fn::Select':
            - Size
            - 'Fn::Select':
                - '{{ ACS::TaskLoopItem }}'
                - '{{ queryDisks.systemDisks }}'
        SystemDiskDiskName:
          'Fn::Select':
            - DiskName
            - 'Fn::Select':
                - '{{ ACS::TaskLoopItem }}'
                - '{{ queryDisks.systemDisks }}'
        SystemDiskPerformanceLevel:
          'Fn::Select':
            - PerformanceLevel
            - 'Fn::Select':
                - '{{ ACS::TaskLoopItem }}'
                - '{{ queryDisks.systemDisks }}'
        InstanceType: '{{ targetInstanceType }}'
        SecurityGroupId: '{{ targetSecurityGroupId }}'
        VSwitchId: '{{ targetVSwitchId }}'
    Loop:
      Items:
        'Fn::Jq':
          - All
          - '.|length|range(.)'
          - '{{ instanceIds }}'
      Outputs:
        instanceIds:
          AggregateType: 'Fn::ListJoin'
          AggregateField: instanceId
    Outputs:
      instanceId:
        Type: String
        ValueSelector: 'InstanceIdSets.InstanceIdSet[]'
  - Name: untilInstanceReady
    Action: 'ACS::WaitFor'
    Description:
      en: Wait for instances running
      zh-cn: Waits for the instance to be created.
    Properties:
      Service: ECS
      API: DescribeInstances
      Parameters:
        RegionId: '{{ targetRegionId }}'
        InstanceIds: '{{ runInstances.instanceIds }}'
      DesiredValues:
        - Running
      PropertySelector: '.Instances.Instance[].Status'
Outputs:
  instanceIds:
    Value: '{{ runInstances.instanceIds }}'
    Type: List
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - targetRegionId
          - targetZoneId
          - targetInstanceType
          - targetSecurityGroupId
          - targetVSwitchId
        Label:
          default:
            zh-cn: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - regionId
          - instanceIds
        Label:
          default:
            zh-cn: Select ECS Instances
            en: Select Ecs Instances
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Control Options
            en: Control Options