Template name
ACS-ECS-ScheduleToCleanUpDisks
Template description
Cleans up disks as scheduled.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
timerTrigger | The type of the scheduled task. | Json | Yes | ||
targets | The Elastic Compute Service (ECS) instances whose disks in which you want to clean up data. | Json | Yes | ||
cleanUpInfos | The rule for cleaning up data in disks. | String | Yes | Regular expression for string verification: [""\s]+ | | |
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
rateControl | The rate control settings. | Json | No | {'Mode': 'Concurrency', 'MaxErrors': '0', 'Concurrency': 10} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | OOSServiceRole |
Output parameters
Parameter | Description | Type |
commandOutputs | List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-ScheduleToCleanUpDisks.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Schedule to clean up disks
zh-cn: the description in Chinese
name-en: Cleanup Disks
name-zh-cn: the description in Chinese
categories:
- time_trigger
- application_manage
- computenest
Parameters:
timerTrigger:
Type: Json
Label:
en: TimerTrigger
zh-cn: the description in Chinese
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
regionId:
Type: String
Label:
en: RegionId
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: the description in Chinese
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: 'ALIYUN::ECS::Instance'
RegionId: regionId
Status: Running
cleanUpInfos:
Description:
en: 'Format: 3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log.'
zh-cn: the description in Chinese
Label:
en: CleanUpRule
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::OOS::Component::CleanUpInfo
AllowedPattern: "^[^\"$`'\\s]+$"
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:
'Fn::Select':
- type
- '{{timerTrigger}}'
Expression:
'Fn::Select':
- expression
- '{{timerTrigger}}'
EndDate:
'Fn::Select':
- endDate
- '{{ timerTrigger }}'
TimeZone:
'Fn::Select':
- timeZone
- '{{ timerTrigger }}'
- 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: cleanUpDisk
Action: 'ACS::ECS::CleanUpDisk'
Description:
en: Execute cloud assistant command to clean up disk
zh-cn: the description in Chinese
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ ACS::TaskLoopItem }}'
cleanUpInfos: '{{ cleanUpInfos }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
Outputs:
commandOutputs:
Type: List
Value: '{{ cleanUpDisk.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- timerTrigger
Label:
default:
zh-cn: the description in Chinese
en: The time of cleanup disk
- Parameters:
- cleanUpInfos
Label:
default:
zh-cn: the description in Chinese
en: The rule of cleanup disk
- 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