ACS-ECS-BulkyCopyImage

模板名称

ACS-ECS-BulkyCopyImage 批量跨地域克隆镜像

立即执行

模板描述

批量跨地域克隆镜像

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

imageId

源镜像ID

String

regionId

地域ID

String

{{ ACS::RegionId }}

targetRegionIds

目标地域ID

List

[‘all-regions’]

rateControl

任务执行的并发比率

Json

{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 5}

OOSAssumeRole

OOS扮演的RAM角色

String

“”

输出参数

参数名称

描述

类型

imageIds

List

执行此模板需要的权限策略

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CopyImage",
                "ecs:DescribeImages",
                "ecs:DescribeRegions"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

详情

ACS-ECS-BulkyCopyImage详情

模板内容

FormatVersion: OOS-2019-06-01
Description:
  en: Cross Regions copy image
  zh-cn: 批量跨地域克隆镜像
  name-en: ACS-ECS-BulkyCopyImage
  name-zh-cn: 批量跨地域克隆镜像
  categories:
    - image_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  imageId:
    Label:
      en: ImageId
      zh-cn: 源镜像ID
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
    AssociationPropertyMetadata:
      RegionId: regionId
  targetRegionIds:
    Label:
      en: TargetRegionIds
      zh-cn: 目标地域ID
    Type: List
    AllowedValues:
      - all-regions
      - cn-qingdao
      - cn-beijing
      - cn-zhangjiakou
      - cn-huhehaote
      - cn-hangzhou
      - cn-shanghai
      - cn-shenzhen
      - cn-chengdu
      - cn-hongkong
      - cn-heyuan
      - cn-wulanchabu
      - ap-northeast-1
      - ap-southeast-1
      - ap-southeast-2
      - ap-southeast-3
      - ap-southeast-5
      - ap-south-1
      - us-east-1
      - us-west-1
      - eu-west-1
      - me-east-1
      - eu-central-1
      - cn-guangzhou
      - ap-southeast-6
      - cn-fuzhou
      - ap-northeast-2
      - ap-southeast-7
      - me-central-1
      - cn-nanjing
      - cn-wuhan-lr
    Default:
      - all-regions
  rateControl:
    Label:
      en: RateControl
      zh-cn: 任务执行的并发比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 5
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: queryAllAvailableRegions
    Action: 'ACS::ExecuteAPI'
    Description:
      en: View all available regions
      zh-cn: 查询当前所有可用地域
    Properties:
      Service: ECS
      API: DescribeRegions
      Parameters:
        RegionId: '{{ACS::RegionId}}'
    Outputs:
      regionIds:
        Type: List
        ValueSelector: >-
          Regions.Region[]|.RegionId|select([scan("{{ACS::RegionId}}|test")]|length<1)
      allRegionsChosen:
        Type: String
        ValueSelector: '.|{{targetRegionIds}}|sort|.[0]'
  - Name: whetherCloneToAllRegions
    Action: 'ACS::Choice'
    Description:
      en: Choose next task by targetRegionIds Chosen
      zh-cn: 根据所选目的地域判断下一步执行
    Properties:
      DefaultTask: copyImage
      Choices:
        - When:
            'Fn::Equals':
              - all-regions
              - '{{ queryAllAvailableRegions.allRegionsChosen }}'
          NextTask: copyImageToAllRegions
  - Name: copyImage
    Action: 'ACS::ECS::CopyImage'
    OnSuccess: 'ACS::END'
    OnError: 'ACS::END'
    Description:
      en: Copy image to regions chosen
      zh-cn: 复制镜像到被指定的地域
    Properties:
      regionId: '{{ regionId }}'
      imageId: '{{ imageId }}'
      targetRegionId: '{{ ACS::TaskLoopItem }}'
    Loop:
      Items: '{{ targetRegionIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        imageIdsWithRegion:
          AggregateType: 'Fn::ListJoin'
          AggregateField: imageIdWithRegion
    Outputs:
      imageIdWithRegion:
        ValueSelector: '.|(.imageId),"{{ ACS::TaskLoopItem }}"'
        Type: List
  - Name: copyImageToAllRegions
    Action: 'ACS::ECS::CopyImage'
    Description:
      en: Copy image to all available regions
      zh-cn: 复制镜像到所有可用地域
    Properties:
      regionId: '{{ regionId }}'
      imageId: '{{ imageId }}'
      targetRegionId: '{{ ACS::TaskLoopItem }}'
    Loop:
      Items: '{{ queryAllAvailableRegions.regionIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        imageIdsWithRegion:
          AggregateType: 'Fn::ListJoin'
          AggregateField: imageIdWithRegion
    Outputs:
      imageIdWithRegion:
        ValueSelector: '.|(.imageId),"{{ ACS::TaskLoopItem }}"'
        Type: List
Outputs:
  imageIds:
    Type: List
    Value:
      'Fn::If':
        - 'Fn::Equals':
            - all-regions
            - '{{ queryAllAvailableRegions.allRegionsChosen }}'
        - '{{ copyImageToAllRegions.imageIdsWithRegion }}'
        - '{{ copyImage.imageIdsWithRegion }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - regionId
          - imageId
          - targetRegionIds
        Label:
          default:
            zh-cn: 配置参数
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options