テンプレート名
ACS-ESS-LifeCycleDownloadFileAndRunCommand
テンプレートの説明
ライフサイクルフックを使用して、ファイルを Elastic Compute Service (ECS) インスタンスにダウンロードし、ECS インスタンスでコマンドを実行します。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
sourcePath | 保存されているファイルの URL。 | String | はい | ||
destinationDir | ECS インスタンスでファイルをダウンロードするディレクトリ。 | String | はい | ||
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 | ECS インスタンスに関連付けられた特定のスケーリングアクティビティのトークン。 | String | いいえ | ${lifecycleActionToken} | |
rateControl | レート制御設定。 | Json | いいえ | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によってアシュームされる RAM ロール。 | String | いいえ | OOSServiceRole |
出力パラメーター
なし
テンプレートを実行するために必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
詳細については、GitHub の ACS-ESS-LifeCycleDownloadFileAndRunCommand.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: Use lifecycleHook to download file and run command in the specified scaling activity instance
name-en: ACS-ESS-LifeCycleDownloadFileAndRunCommand
categories:
- elastic_manage
Parameters:
sourcePath:
Type: String
Label:
en: SourcePath
destinationDir:
Label:
en: DestinationDir
Type: String
whetherSaveToFile:
Label:
en: whetherSaveToFile
Type: Boolean
Default: true
commandContent:
Label:
en: CommandContent
Type: String
AssociationProperty: Code
Default: echo hello
timeout:
Label:
en: Timeout
Type: Number
Default: 600
regionId:
Label:
en: RegionId
Description:
en: The ID of region
Type: String
Default: '${regionId}'
instanceIds:
Label:
en: InstanceIds
Description:
en: The ID list of the ECS instance
Type: List
Default:
- '${instanceIds}'
lifecycleHookId:
Label:
en: LifecycleHookId
Description:
en: The ID of the lifecycle hook
Type: String
Default: '${lifecycleHookId}'
lifecycleActionToken:
Label:
en: LifecycleActionToken
Description:
en: The token that indicates a specific scaling activity associated with an instance
Type: String
Default: '${lifecycleActionToken}'
rateControl:
Label:
en: RateControl
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: downloadFileAndRunCommand
OnError: CompleteLifecycleActionForAbandon
OnSuccess: CompleteLifecycleActionForContinue
Action: ACS::ESS::DownloadFileAndRunCommand
Description:
en: Downloads file to the ECS instances adn run command
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
sourceType: https
sourcePath: '{{ sourcePath }}'
destinationDir: '{{ destinationDir }}'
whetherSaveToFile: '{{ whetherSaveToFile }}'
commandContent: '{{ commandContent }}'
timeout: '{{ timeout }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ instanceIds }}'
- Name: CompleteLifecycleActionForContinue
Action: 'ACS::ExecuteAPI'
Description:
en: Modify lifecycle action for 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: Complete lifecycle action for Abandon
Properties:
Service: ESS
API: CompleteLifecycleAction
Parameters:
RegionId: '{{ regionId }}'
LifecycleHookId: '{{ lifecycleHookId }}'
LifecycleActionToken: '{{ lifecycleActionToken }}'
LifecycleActionResult: ABANDON