テンプレート名
ACS-ECS-ScheduleToStopInstances
テンプレートの説明
スケジュールに従って Elastic Compute Service ( ECS ) インスタンスを停止します。これは、指定した時間に ECS インスタンスを停止する場合に適用されます。このテンプレートを構成する場合は、次のパラメーターを指定する必要があります。regionId:ECS インスタンスのリージョン、cron:タスクをトリガーするルール、targets:停止するインスタンス。テンプレートが実行されると、指定された ECS インスタンスは指定された時間に停止されます。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
endDate | スケジュールされたタスクの終了時間。 | String | はい | ||
targets | 停止する ECS インスタンス。 | Json | はい | ||
regionId | リージョン ID。 | String | いいえ | {{ ACS::RegionId }} | |
cron | CRON 式。 | String | いいえ | 0 0 12 ? * * | |
timeZone | タイムゾーン。 | String | いいえ | UTC | |
rateControl | レート制御設定。 | Json | いいえ | {'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10} | |
OOSAssumeRole | CloudOps Orchestration Service ( OOS ) によってアシュームされる Resource Access Management ( RAM ) ロール。 | String | いいえ | OOSServiceRole |
出力パラメーター
パラメーター | 説明 | タイプ |
instanceIds | List |
テンプレートの実行に必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
詳細については、GitHub の ACS-ECS-ScheduleToStopInstances.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: 'Schedule to stop the ECS instances, applicable to scenarios where ECS instances need to be stopped at scheduled times, such as automatically stopping development or test environments to save costs. During configuration, users need to provide the following required parameter information: Region ID (regionId), which specifies the region of the ECS instances to be operated on, Cron Expression (cron), which defines the schedule for the task, and Target Instances (targets), which defines the specific ECS instances to be operated on. Upon execution, the template will stop the ECS instances according to the configured schedule.'
zh-cn: the description in Chinese
name-en: ACS-ECS-ScheduleToStopInstances
name-zh-cn: the description in Chinese
categories:
- time_trigger
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
cron:
Description:
en: 'refer them here: https://help.aliyun.com/document_detail/169784.html'
zh-cn: the description in Chinese
Label:
en: CronExpression
zh-cn: the description in Chinese
Type: String
AssociationProperty: Cron
Default: 0 0 12 ? * *
endDate:
Description:
en: 'Format: yyyy-MM-ddTHH:mm:ssZ.'
zh-cn: the description in Chinese
Label:
en: EndDate
zh-cn: the description in Chinese
Type: String
AssociationProperty: DateTime
AssociationPropertyMetadata:
Format: 'YYYY-MM-DDTHH:mm:ssZ'
timeZone:
Label:
en: TimeZone
zh-cn: the description in Chinese
Type: String
AssociationProperty: TimeZone
Default: UTC
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: the description in Chinese
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: ACS::TimerTrigger
Description:
en: Triggers a task as scheduled by specifying type and expression
zh-cn: the description in Chinese
Properties:
Type: cron
Expression: '{{ cron }}'
EndDate: '{{ endDate }}'
TimeZone: '{{ timeZone }}'
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: the description in Chinese
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: stopInstance
Action: ACS::ECS::StopInstance
Description:
en: Stops the ECS instances
zh-cn: the description in Chinese
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
instanceIds:
Type: List
Value: '{{ getInstance.instanceIds }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- timeZone
- cron
- endDate
Label:
default:
zh-cn: the description in Chinese
en: Timer Trigger Configure
- Parameters:
- regionId
- targets
Label:
default:
zh-cn: the description in Chinese
en: Select ECS Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options