Template name
ACS-ECS-ScheduleToUpgradeInternetBandwidthNew
Template description
Temporarily upgrades the bandwidth for multiple Elastic Compute Service (ECS) instances as scheduled.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | The ECS instances for which you want to temporarily upgrade bandwidth. | Json | Yes | ||
timerTrigger | The mode in which the scheduled task is run. | Json | Yes | ||
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
maxBandwidthOut | The maximum outbound public bandwidth. | Number | No | 10 | |
durationHour | The duration of the bandwidth upgrade. | Number | No | 4 | |
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 | AliyunServiceRoleForOOSBandwidthScheduler |
Output parameters
None
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:ModifyInstanceNetworkSpec"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-ScheduleToUpgradeInternetBandwidthNew.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Schedule to upgrades internet bandwidth for ECS instances
zh-cn: the description in Chinese
name-en: ACS-ECS-ScheduleToUpgradeInternetBandwidthNew
name-zh-cn: the description in Chinese
categories:
- time_trigger
Parameters:
regionId:
Type: String
Label:
en: The id of region
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
InternetChargeType: PayByBandwidth
ChargeType: PrePaid
timerTrigger:
Type: Json
Label:
en: TimerTrigger
zh-cn: the description in Chinese
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
maxBandwidthOut:
Label:
en: The maximum public network bandwidth for out-direction
zh-cn: the description in Chinese
Description:
zh-cn: the description in Chinese
zh-cn: the description in Chinese
Type: Number
MinValue: 0
MaxValue: 100
Default: 10
durationHour:
Label:
en: The number of hours that the bandwidth upgrade lasts
zh-cn: the description in Chinese
Description:
zh-cn: the description in Chinese
en: 'Unit: Hour. The bandwidth upgrade should last at least 4 hours. Upgrade only ends on the hour'
Type: Number
MinValue: 4
Default: 4
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: The RAM role to be assumed by OOS
zh-cn: the description in Chinese
Type: String
Default: AliyunServiceRoleForOOSBandwidthScheduler
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: modifyInstanceNetworkSpec
Action: ACS::ExecuteAPI
Description:
en: Modifies the temporary bandwidth of the instances
zh-cn: the description in Chinese
Properties:
Service: ECS
API: ModifyInstanceNetworkSpec
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ ACS::TaskLoopItem }}'
InternetMaxBandwidthOut: '{{ maxBandwidthOut }}'
EndTime:
Fn::FormatUTCTime:
- Fn::AddHour:
- '{{ ACS::CurrentUTCTime }}'
- '{{ durationHour }}'
- '%Y-%m-%dT%HZ'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'