Template name
ACS-ECS-ScheduleToAcceptInquiredSystemEvent: Periodically accepts and authorizes system event operations.
Template description
Accepts the default operation for a system event and authorizes the system to perform the default operation as scheduled. Procedure:
Stop an Elastic Compute Service (ECS) instance.
Accept the default operation for a system event and authorize the system to perform the default operation.
Start the ECS instance.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
timerTrigger | The type of the scheduled task. | Json | Yes | ||
instanceId | The ID of the ECS instance. | String | Yes | ||
eventId | The ID of a system event. | String | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | AliyunServiceRoleForOOSSystemEventOperator |
Output parameters
None
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:AcceptInquiredSystemEvent",
"ecs:DescribeInstances",
"ecs:StartInstance",
"ecs:StopInstance"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
For more information, see ACS-ECS-ScheduleToAcceptInquiredSystemEvent.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: <p>Schedules the acceptance of a system event and authorizes its execution. The process is as follows: <ol><li>Stops the ECS instance.</li><li>Accepts the inquired system event.</li><li>Starts the ECS instance.</li</ol></p>
zh-cn: <p>Schedules the acceptance of a system event and authorizes its execution. The process is as follows: <ol><li>Stops the ECS instance.</li><li>Accepts the inquired system event.</li><li>Starts the ECS instance.</li</ol></p>
name-en: ACS-ECS-ScheduleToAcceptInquiredSystemEvent
name-zh-cn: Schedules the acceptance of a system event and authorizes its execution.
categories:
- time_trigger
Parameters:
timerTrigger:
Type: Json
Label:
en: TimerTrigger
zh-cn: Timer type
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
regionId:
Label:
en: RegionId
zh-cn: Region ID
Type: String
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Label:
en: ECSInstanceId
zh-cn: ECS instance ID
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
eventId:
Label:
en: EventId
zh-cn: System event ID
Type: String
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: The RAM role that is assumed by OOS.
Type: String
Default: AliyunServiceRoleForOOSSystemEventOperator
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: ACS::TimerTrigger
Description:
en: Triggers a task as scheduled by specifying type and expression.
zh-cn: Triggers a task as scheduled by specifying the type and expression.
Properties:
Type:
Fn::Select:
- type
- '{{timerTrigger}}'
Expression:
Fn::Select:
- expression
- '{{timerTrigger}}'
StartDate:
Fn::Select:
- startDate
- '{{ timerTrigger }}'
EndDate:
Fn::Select:
- endDate
- '{{ timerTrigger }}'
TimeZone:
Fn::Select:
- timeZone
- '{{ timerTrigger }}'
- Name: getInstance
Action: ACS::SelectTargets
Description:
en: Obtains the ECS instance.
zh-cn: Obtains the ECS instance.
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- Type: ResourceIds
RegionId: '{{ regionId }}'
ResourceIds:
- '{{ instanceId }}'
Outputs:
instanceId:
Type: String
ValueSelector: Instances.Instance[].InstanceId
status:
Type: String
ValueSelector: Instances.Instance[].Status
- Name: checkForWhetherResourceExist
Action: ACS::Choice
Description:
en: Checks whether the resource exists.
zh-cn: Checks whether the resource exists.
Properties:
DefaultTask: stopInstance
Choices:
- When:
Fn::Equals:
- Null
- '{{ getInstance.instanceId }}'
NextTask: ACS::END
- Name: stopInstance
Action: ACS::ECS::StopInstance
Description:
en: Stops the ECS instance.
zh-cn: Stops the ECS instance.
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ getInstance.instanceId }}'
- Name: acceptInquiredSystemEvent
Action: ACS::ExecuteApi
Description:
en: Accepts and authorizes system event actions.
zh-cn: Accepts and authorizes system event actions.
Properties:
Service: ECS
API: AcceptInquiredSystemEvent
Parameters:
RegionId: '{{ regionId }}'
EventId: '{{ eventId }}'
- Name: startInstance
Action: ACS::ECS::StartInstance
When:
Fn::Equals:
- Running
- '{{ getInstance.status }}'
Description:
en: Starts the ECS instance.
zh-cn: Starts the ECS instance.
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ getInstance.instanceId }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- timerTrigger
Label:
default:
zh-cn: Timer Settings
en: Timer Settings
- Parameters:
- regionId
- instanceId
- eventId
Label:
default:
zh-cn: Select Instance
en: Select Instance
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: Advanced Options
en: Advanced Options