All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-BulkyCopyImage

Last Updated:Sep 20, 2024

Template name

ACS-ECS-BulkyCopyImage

Execute Now

Template description

Clones an image to multiple regions at a time.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

imageId

The ID of the source image.

String

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

targetRegionIds

The IDs of the regions to which the image is cloned.

List

No

['all-regions']

rateControl

The rate control settings.

Json

No

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

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Type

imageIds

List

Permission policy that is required to execute the template

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

References

For more information, see ACS-ECS-BulkyCopyImage.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Cross Regions copy image
  zh-cn: the description in Chinese
  name-en: ACS-ECS-BulkyCopyImage
  name-zh-cn: the description in Chinese
  categories:
    - image_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  imageId:
    Label:
      en: ImageId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: 'ALIYUN::ECS::Image::ImageId'
    AssociationPropertyMetadata:
      RegionId: regionId
  targetRegionIds:
    Label:
      en: TargetRegionIds
      zh-cn: the description in Chinese
    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: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 5
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: queryAllAvailableRegions
    Action: 'ACS::ExecuteAPI'
    Description:
      en: View all available regions
      zh-cn: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
    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: the description in Chinese
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Control Options