全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-ECS-CreateImageAndUpdateLaunchTemplates

更新時間:Sep 06, 2024

模板名稱

ACS-ECS-CreateImageAndUpdateLaunchTemplates 建立ECS鏡像並更新啟動模板

立即執行

模板描述

建立ECS鏡像並更新啟動模板

模板類型

自動化

所有者

Alibaba Cloud

輸入參數

參數名稱

描述

類型

是否必填

預設值

約束

instanceId

ECS執行個體ID

String

regionId

地區ID

String

{{ ACS::RegionId }}

targetImageName

新鏡像的名稱

String

CreateImage_from_{{instanceId}}

launchTemplateNames

待更新的執行個體啟動模板名稱列表

List

[]

tags

鏡像標籤

Json

[]

deleteSourceTemplateVersion

刪除啟動模板的原版本

Boolean

True

rateControl

任務執行的並發比率

Json

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

OOSAssumeRole

OOS扮演的RAM角色

String

“”

輸出參數

參數名稱

描述

類型

imageIds

List

執行此模板需要的權限原則

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CreateImage",
                "ecs:CreateLaunchTemplateVersion",
                "ecs:DeleteLaunchTemplateVersion",
                "ecs:DescribeDisks",
                "ecs:DescribeImages",
                "ecs:DescribeInstances",
                "ecs:DescribeLaunchTemplateVersions",
                "ecs:DescribeLaunchTemplates",
                "ecs:ModifyLaunchTemplateDefaultVersion"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳情

ACS-ECS-CreateImageAndUpdateLaunchTemplates詳情

模板內容

FormatVersion: OOS-2019-06-01
Description:
  name-en: ACS-ECS-CreateImageAndUpdateLaunchTemplates
  name-zh-cn: 建立ECS鏡像並更新啟動模板
  en: Creates an ECS image and update launch template
  zh-cn: 建立ECS鏡像並更新啟動模板
  categories:
    - image_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地區ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: InstanceId
      zh-cn: ECS執行個體ID
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
  targetImageName:
    Label:
      en: TargetImageName
      zh-cn: 新鏡像的名稱
    Type: String
    Description:
      en: <p class="p">Note:</p> <ul class="ul"> <li class="li">Length is 2~128 English or Chinese characters</li> <li class="li"><font color='red'>must start with big or small letters or Chinese, not http:// and https://. </font></li> <li class="li">Can contain numbers, colons (:), underscores (_), or dashes (-). </li> </ul>
      zh-cn: <p class="p">注意:</p> <ul class="ul"> <li class="li">長度為2~128個英文或中文字元</li> <li class="li"><font color='red'>必須以大小字母或中文開頭,不能以http://和https://開頭。</font></li> <li class="li">可以包含數字、半形冒號(:)、底線(_)或者短劃線(-)。</li> </ul>
    Default: CreateImage_from_{{instanceId}}
  launchTemplateNames:
    Description:
      en: <font color='red'><b>Must correspond to the selected region</b></font>
      zh-cn: <font color='red'><b>必須要在所選的地區</b></font>
    Label:
      en: LaunchTemplateNames
      zh-cn: 待更新的執行個體啟動模板名稱列表
    Type: List
    Default: []
  tags:
    Label:
      en: Tags
      zh-cn: 鏡像標籤
    Type: Json
    AssociationProperty: Tags
    AssociationPropertyMetadata:
      ShowSystem: false
    Default: []
  deleteSourceTemplateVersion:
    Label:
      en: DeleteSourceTemplateVersion
      zh-cn: 刪除啟動模板的原版本
    Type: Boolean
    Default: true
  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: createImage
  Action: 'ACS::ECS::CreateImage'
  Description:
    en: Create new image with the specified image name and instance ID
    zh-cn: 通過指定執行個體ID和鏡像名稱建立新的鏡像
  Properties:
    regionId: '{{ regionId }}'
    instanceId: '{{ instanceId }}'
    imageName: '{{ targetImageName }}_on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }}'
    tags: '{{tags}}'
  Outputs:
    imageId:
      ValueSelector: imageId
      Type: String
- Name: describeDisks
  Action: 'ACS::ExecuteAPI'
  Description:
    en: Get disk info of the ECS instance
    zh-cn: 查看執行個體的磁碟資訊
  Properties:
    Service: ECS
    API: DescribeDisks
    Parameters:
      RegionId: '{{ regionId }}'
      InstanceId: '{{ instanceId }}'
  Outputs:
    systemDiskSize:
      Type: String
      ValueSelector: '.Disks.Disk[] | select(.Type == "system" )|.Size'
    systemDiskPerformanceLevel:
      Type: String
      ValueSelector: '.Disks.Disk[] | select(.Type == "system" )|.PerformanceLevel'
    systemDiskDeleteWithInstance:
      Type: Boolean
      ValueSelector: '.Disks.Disk[] | select(.Type == "system" )|.DeleteWithInstance'
- Name: updateLaunchTemplate
  Action: 'ACS::ECS::UpdateLaunchTemplate'
  Description:
    en: Update instance launch template
    zh-cn: 更新執行個體啟動模板
  Properties:
    regionId: '{{ regionId }}'
    imageId: '{{ createImage.imageId }}'
    launchTemplateName: '{{ ACS::TaskLoopItem }}'
    deleteSourceTemplateVersion: '{{ deleteSourceTemplateVersion }}'
    systemDiskSize: '{{ describeDisks.systemDiskSize}}'
    systemDiskPerformanceLevel: '{{ describeDisks.systemDiskPerformanceLevel }}'
    systemDiskDeleteWithInstance: '{{ describeDisks.systemDiskDeleteWithInstance }}'
  Loop:
    Items: '{{ launchTemplateNames }}'
Outputs:
  imageIds:
    Type: List
    Value: '{{ createImage.imageId }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - regionId
          - instanceId
        Label:
          default:
            zh-cn: 選擇執行個體
            en: Select Ecs Instances
      - Parameters:
          - targetImageName
          - tags
        Label:
          default:
            zh-cn: 鏡像設定
            en: Image Configure
      - Parameters:
          - launchTemplateNames
          - deleteSourceTemplateVersion
        Label:
          default:
            zh-cn: 啟動模板
            en: Launch Template
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 進階選項
            en: Control Options