ACS-ECS-BulkyCreateAndExportImage

模板名称

ACS-ECS-BulkyCreateAndExportImage 批量创建并导出镜像到OSS-Bucket

立即执行

模板描述

批量创建并导出镜像到OSS-Bucket

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

targets

目标实例

Json

OSSBucket

保存导出镜像的OSS bucket

String

tags

镜像标签

Json

[]

rateControl

任务执行的并发比率

Json

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

OOSAssumeRole

OOS扮演的RAM角色

String

“”

输出参数

参数名称

描述

类型

imageIds

List

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

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

详情

ACS-ECS-BulkyCreateAndExportImage详情

模板内容

FormatVersion: OOS-2019-06-01
Description:
  en: Bulky creates ECS image and exports them into OSS
  zh-cn: 批量创建并导出镜像到OSS-Bucket
  name-en: ACS-ECS-BulkyCreateAndExportImage
  name-zh-cn: 批量创建并导出镜像到OSS-Bucket
  categories:
    - image_manage
Parameters:
  targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: 目标实例
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
  OSSBucket:
    Label:
      en: OSSBucket
      zh-cn: 保存导出镜像的OSS bucket
    Type: String
  tags:
    Label:
      en: Tags
      zh-cn: 镜像标签
    Type: Json
    AssociationProperty: Tags
    AssociationPropertyMetadata:
      ShowSystem: false
    Default: []
  rateControl:
    Label:
      en: RateControl
      zh-cn: 任务执行的并发比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
  Description:
    en: Views the ECS instances
    zh-cn: 获取ECS实例
  Action: ACS::SelectTargets
  Properties:
    ResourceType: ALIYUN::ECS::Instance
    Filters:
      - '{{ targets }}'
  Outputs:
    instanceIds:
      Type: List
      ValueSelector: Instances.Instance[].InstanceId
- Name: createImage
  Action: ACS::ECS::CreateImage
  Description:
    en: Create new image with the specified image name and instance ID
    zh-cn: 通过指定实例ID和镜像名称创建新的镜像
  Properties:
    instanceId: '{{ ACS::TaskLoopItem }}'
    tags: '{{tags}}'
    imageName: 'image_of_{{ ACS::TaskLoopItem }}_{{ ACS::ExecutionId }}'
  Loop:
    Items: '{{ getInstance.instanceIds }}'
    RateControl: '{{ rateControl }}'
    Outputs:
      imageIds:
        AggregateType: 'Fn::ListJoin'
        AggregateField: imageId
  Outputs:
    imageId:
      ValueSelector: imageId
      Type: String
- Name: importImageToOSS
  Action: ACS::ExecuteApi
  Description:
    en: EXport image to OSS bucket
    zh-cn: 导出镜像到OSS-Bucket
  Properties:
    Service: ECS
    API: ExportImage
    Parameters:
      ImageId: '{{ ACS::TaskLoopItem }}'
      OSSBucket: '{{ OSSBucket }}'
  Loop:
    Items: '{{ createImage.imageIds }}'
    RateControl: '{{ rateControl }}'
Outputs:
  imageIds:
    Type: List
    Value: '{{ createImage.imageIds }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - targets
          - OSSBucket
          - tags
        Label:
          default:
            zh-cn: 配置参数
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options