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

CloudOps Orchestration Service:ACS-ECS-イメージの作成と起動テンプレートの更新

最終更新日:Jan 17, 2025

テンプレート名

ACS-ECS-CreateImageAndUpdateLaunchTemplates

今すぐ実行

テンプレートの説明

Elastic Compute Service (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

CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (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"
        }
    ]
}

参照

詳細については、GitHub の ACS-ECS-CreateImageAndUpdateLaunchTemplates.yml をご参照ください。

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  name-en: ACS-ECS-CreateImageAndUpdateLaunchTemplates
  name-zh-cn: 中国語の説明
  en: Creates an ECS image and update launch template
  zh-cn: 中国語の説明
  categories:
    - image_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 中国語の説明
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: InstanceId
      zh-cn: 中国語の説明
    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: 中国語の説明
    Default: CreateImage_from_{{instanceId}}
  launchTemplateNames:
    Description:
      en: <font color='red'><b>Must correspond to the selected region</b></font>
      zh-cn: 中国語の説明
    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: 中国語の説明
    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: 中国語の説明
  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