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

CloudOps Orchestration Service:ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand

最終更新日:Dec 21, 2025

テンプレート名

ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand - ライフサイクルフックを使用して、OSS ファイルを ECS インスタンスにダウンロードし、コマンドを実行します。

今すぐ実行

テンプレートの説明

ライフサイクルフックを使用して、Object Storage Service (OSS) オブジェクトを Elastic Compute Service (ECS) インスタンスにダウンロードし、ECS インスタンスでコマンドを実行します。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

bucketName

OSS バケットの名前。

String

はい

objectName

OSS オブジェクトの名前。

String

はい

destinationDir

インスタンス上でファイルをコピーするターゲットディレクトリ。

String

はい

URLExpirationTime

OSS オブジェクトのダウンロード URL の有効期間。

Number

いいえ

6000

OSSRegion

OSS バケットが存在するリージョン。

String

いいえ

{{ ACS::RegionId }}

whetherSaveToFile

ファイルの内容を特定のファイルに保存するかどうかを指定します。

Boolean

いいえ

True

commandContent

ECS インスタンスで実行されるクラウドアシスタントコマンド。

String

いいえ

echo hello

timeout

ECS インスタンスでコマンドを実行するためのタイムアウト期間。

Number

いいえ

600

regionId

リージョン ID。

String

いいえ

${regionId}

instanceIds

ECS インスタンスの ID。

List

いいえ

['${instanceIds}']

lifecycleHookId

ライフサイクルフック ID。

String

いいえ

${lifecycleHookId}

lifecycleActionToken

インスタンスに関連付けられている特定のスケーリングアクティビティのトークン。

String

いいえ

${lifecycleActionToken}

rateControl

レート制御設定。

Json

いいえ

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

OOSAssumeRole

CloudOps Orchestration Service (OOS) によってアシュームされる Resource Access Management (RAM) ロール。

String

いいえ

OOSServiceRole

出力パラメーター

なし

テンプレートを実行するために必要なポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "oss:GetObject"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ess:CompleteLifecycleAction"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳細

ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  en: Uses a lifecycle hook to download an OSS file to the ECS instance of a specified scaling activity and run a command.
  zh-cn: Uses a lifecycle hook to download an OSS file to the ECS instance of a specified scaling activity and run a command.
  ja: ライフサイクルフックを使用して、指定されたスケーリングアクティビティの ECS インスタンスに OSS ファイルをダウンロードし、コマンドを実行します。
  name-en: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand
  name-zh-cn: Uses a lifecycle hook to download an OSS file to an ECS instance and run a command.
  name-ja: ACS-ESS-LifeCycleDownloadOSSFileAndRunCommand
  categories:
    - elastic_manage
Parameters:
  bucketName:
    Label:
      en: BucketName
      zh-cn: The name of the OSS bucket.
      ja: バケット名
    Type: String
  objectName:
    Label:
      en: ObjectName
      zh-cn: The name of the OSS object.
      ja: オブジェクト名
    Type: String
  URLExpirationTime:
    Label:
      en: OSSFileDownloadURLExpirationTime
      zh-cn: The expiration time of the OSS file download URL.
      ja: OSS ファイルダウンロード URL の有効期限
    Description:
      en: The time-to-live (TTL), in seconds, for the download URL of the OSS object.
      zh-cn: The time-to-live (TTL), in seconds, for the download URL of the OSS object.
      ja: OSS オブジェクトのダウンロード URL の生存時間 (TTL) (単位: 秒)。
    Type: Number
    Default: 6000
  OSSRegion:
    Label:
      en: OSSRegion
      zh-cn: The region where the OSS bucket is located.
      ja: OSS リージョン
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  destinationDir:
    Label:
      en: DestinationDir
      zh-cn: The destination directory on the instance to which the file is copied.
      ja: 宛先ディレクトリ
    Type: String
  whetherSaveToFile:
    Label:
      en: whetherSaveToFile
      zh-cn: Specifies whether to download the content to a specific file.
      ja: ファイルに保存するかどうか
    Type: Boolean
    Default: true
  commandContent:
    Label:
      en: CommandContent
      zh-cn: The Cloud Assistant command to run on the ECS instance.
      ja: コマンドの内容
    Type: String
    AssociationProperty: Code
    Default: echo hello
  timeout:
    Label:
      en: Timeout
      zh-cn: The timeout period for running the command on the ECS instance.
      ja: タイムアウト
    Type: Number
    Default: 600
  regionId:
    Label:
      en: RegionId
      zh-cn: The region ID.
      ja: リージョン ID
    Description:
      en: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
      zh-cn: The ID of the region. Use the default value ${regionId} provided by Auto Scaling.
      ja: リージョン ID。Auto Scaling によって提供されるデフォルト値 ${regionId} を使用します。
    Type: String
    Default: '${regionId}'
  instanceIds:
    Label:
      en: InstanceIds
      zh-cn: A list of ECS instance IDs.
      ja: インスタンス ID
    Description:
      en: A list of ECS instance IDs. Use the default value ["${instanceId}"] provided by Auto Scaling.
      zh-cn: A list of ECS instance IDs. Use the default value ["${instanceId}"] provided by Auto Scaling.
      ja: ECS インスタンス ID のリスト。Auto Scaling によって提供されるデフォルト値 ["${instanceId}"] を使用します。
    Type: List
    Default:
      - '${instanceIds}'
  lifecycleHookId:
    Label:
      en: LifecycleHookId
      zh-cn: The ID of the lifecycle hook.
      ja: ライフサイクルフック ID
    Description:
      en: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
      zh-cn: The ID of the lifecycle hook. Use the default value ${lifecycleHookId} provided by Auto Scaling.
      ja: ライフサイクルフックの ID。Auto Scaling によって提供されるデフォルト値 ${lifecycleHookId} を使用します。
    Type: String
    Default: '${lifecycleHookId}'
  lifecycleActionToken:
    Label:
      en: LifecycleActionToken
      zh-cn: The token for the scaling activity that is associated with the instance.
      ja: ライフサイクルアクショントークン
    Description:
      en: The token for the scaling activity that is associated with the instance. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
      zh-cn: The token for the scaling activity that is associated with the instance. Use the default value ${lifecycleActionToken} provided by Auto Scaling.
      ja: インスタンスに関連付けられているスケーリングアクティビティのトークン。Auto Scaling によって提供されるデフォルト値 ${lifecycleActionToken} を使用します。
    Type: String
    Default: '${lifecycleActionToken}'
  rateControl:
    Label:
      en: RateControl
      zh-cn: Rate control.
      ja: レート制御
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: The RAM role that OOS assumes.
      ja: OOS が偽装するロール
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: downloadFileAndRunCommand
    OnError: CompleteLifecycleActionForAbandon
    OnSuccess: CompleteLifecycleActionForContinue
    Action: ACS::ECS::DownloadOSSFileAndRunCommand
    Description:
      en: Downloads a file to the ECS instances and runs a command.
      zh-cn: Downloads a file to the ECS instances and runs a command.
      ja: ファイルを ECS インスタンスにダウンロードし、コマンドを実行します。
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      bucketName: '{{ bucketName }}'
      objectName: '{{ objectName }}'
      URLExpirationTime: '{{ URLExpirationTime }}'
      OSSRegion: '{{ OSSRegion }}'
      destinationDir: '{{ destinationDir }}'
      whetherSaveToFile: '{{ whetherSaveToFile }}'
      commandContent: '{{ commandContent }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ instanceIds }}'
  - Name: CompleteLifecycleActionForContinue
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Changes the lifecycle action to Continue.
      zh-cn: Changes the lifecycle action to Continue.
      ja: ライフサイクルアクションを Continue に変更します。
    OnSuccess: 'ACS::END'
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: CONTINUE
  - Name: CompleteLifecycleActionForAbandon
    Action: 'ACS::ExecuteAPI'
    Description:
      en: Changes the lifecycle action to Abandon.
      zh-cn: Changes the lifecycle action to Abandon.
      ja: ライフサイクルアクションを Abandon に変更します。
    Properties:
      Service: ESS
      API: CompleteLifecycleAction
      Parameters:
        RegionId: '{{ regionId }}'
        LifecycleHookId: '{{ lifecycleHookId }}'
        LifecycleActionToken: '{{ lifecycleActionToken }}'
        LifecycleActionResult: ABANDON