テンプレート名
ACS-ESS-LifeCycleRunCommandOnSpecifiedInstance
テンプレートの説明
ライフサイクルフックを使用して、特定の Elastic Compute Service (ECS) インスタンスでコマンドを実行します。
テンプレートの種類
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | 種類 | 必須 | デフォルト値 | 制限 |
commandInstanceId | コマンドを実行する ECS インスタンスの ID。 | String | はい | ||
commandContent | クラウドアシスタント コマンドの内容。 | String | いいえ | echo hello | |
regionId | リージョン ID。 | String | いいえ | ${regionId} | |
instanceIds | ECS インスタンスの ID。 | List | いいえ | ['${instanceIds}'] | |
lifecycleHookId | ライフサイクルフック ID。 | String | いいえ | ${lifecycleHookId} | |
lifecycleActionToken | インスタンスに関連付けられている特定のスケーリングアクティビティのトークン。 | String | いいえ | ${lifecycleActionToken} | |
rateControl | レート制御設定。 | Json | いいえ | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 1} | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって仮定される Resource Access Management (RAM) ロール。 | String | いいえ | OOSServiceRole |
出力パラメーター
パラメーター | 説明 | 種類 |
commandOutputs | List |
テンプレートを実行するために必要なポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ess:CompleteLifecycleAction"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
ACS-ESS-LifeCycleRunCommandOnSpecifiedInstance
テンプレートの内容
FormatVersion: OOS-2019-06-01
Description:
en: Use lifecycleHook to run command in the specified scaling activity instance
zh-cn: 使用生命周期挂钩到指定实例中执行命令
name-en: ACS-ESS-LifeCycleRunCommandOnSpecifiedInstance
name-zh-cn: 使用生命周期挂钩到指定实例中执行命令
categories:
- elastic_manage
Parameters:
commandInstanceId:
Label:
en: CommandInstanceId
zh-cn: 実行コマンドの ECS インスタンス ID
Type: String
commandContent:
Label:
en: CommandContent
zh-cn: クラウドアシスタントコマンド
Type: String
AssociationProperty: Code
Default: echo hello
regionId:
Label:
en: RegionId
zh-cn: リージョン ID
Description:
en: The ID of region
zh-cn: 'リージョン ID。デフォルト値 ${regionId} を使用してください。'
Type: String
Default: '${regionId}'
instanceIds:
Label:
en: InstanceIds
zh-cn: ECS インスタンス ID リスト
Description:
en: The ID list of the ECS instance
zh-cn: 'ECS インスタンス ID リスト。デフォルト値 ["${instanceId}"] を使用してください。'
Type: List
Default:
- '${instanceIds}'
lifecycleHookId:
Label:
en: LifecycleHookId
zh-cn: ライフサイクルフック ID
Description:
en: The ID of the lifecycle hook
zh-cn: 'ライフサイクルフック ID。デフォルト値 ${lifecycleHookId} を使用してください。'
Type: String
Default: '${lifecycleHookId}'
lifecycleActionToken:
Label:
en: LifecycleActionToken
zh-cn: インスタンスに関連付けられた特定のスケーリングアクティビティのトークン
Description:
en: The token that indicates a specific scaling activity associated with an instance
zh-cn: 'インスタンスに関連付けられた特定のスケーリングアクティビティのトークン。デフォルト値 ${lifecycleActionToken} を使用してください。'
Type: String
Default: '${lifecycleActionToken}'
rateControl:
Label:
en: RateControl
zh-cn: レート制御
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 1
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS が実行する RAM ロール
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: runCommandOnSpecifiedInstance
Action: ACS::ESS::RunCommandOnSpecifiedInstance
OnError: CompleteLifecycleActionForAbandon
OnSuccess: CompleteLifecycleActionForContinue
Description:
en: Execute cloud assistant command
zh-cn: クラウドアシスタントコマンドを実行する
Properties:
regionId: '{{ regionId }}'
commandContent: '{{ commandContent }}'
commandInstanceId: '{{ commandInstanceId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ instanceIds }}'
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
- Name: CompleteLifecycleActionForContinue
Action: 'ACS::ExecuteAPI'
Description:
en: Modify lifecycle action for continue
zh-cn: スケーリングアクティビティの待機状態を続行完了に変更する
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
zh-cn: スケーリングアクティビティの待機状態を破棄に変更する
Properties:
Service: ESS
API: CompleteLifecycleAction
Parameters:
RegionId: '{{ regionId }}'
LifecycleHookId: '{{ lifecycleHookId }}'
LifecycleActionToken: '{{ lifecycleActionToken }}'
Outputs:
commandOutputs:
Type: List
Value: '{{ runCommandOnSpecifiedInstance.commandOutputs }}'