All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-ScheduleToUpgradeInternetBandwidth

Last Updated:Nov 25, 2024

Template name

ACS-ECS-ScheduleToUpgradeInternetBandwidth

Execute Now

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

regionId

The region ID.

String

No

{{ ACS::RegionId }}

triggerCron

The interval at which the bandwidth upgrade task is run.

String

No

0 0 12 ? * *

triggerEndDate

The end time of the periodic execution.

String

No

2025-12-31T15:59:59Z

timeZone

The time zone of the scheduled execution.

String

No

UTC

maxBandwidthIn

The maximum inbound public bandwidth.

Number

No

10

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

OOSServiceRole

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-ScheduleToUpgradeInternetBandwidth.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-ScheduleToUpgradeInternetBandwidth
  name-zh-cn: Scheduled upgrade of the temporary bandwidth of an ECS instance
  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
  triggerCron:
    Label:
      en: 'The schedule of bandwidth upgrade task'
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: Cron
    Default: 0 0 12 ?  * *
  triggerEndDate:
    Label:
      en: 'The end date of bandwidth upgrade task'
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: DateTime
    AssociationPropertyMetadata:
      Format: 'YYYY-MM-DDTHH:mm:ssZ'
    Default: '2025-12-31T15:59:59Z'
  timeZone:
    Label:
      en: The time zone of schedule
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: TimeZone
    Default: UTC
  maxBandwidthIn:
    Label:
      en: The maximum public network bandwidth for in-direction
      zh-cn: the description in Chinese
    Description:
      en: 'Unit: Mbit/s (Megabit per second), range: 1~10 when maxBandwidthOut<=10Mbit/s, else 1~maxBandwidthOut'
      zh-cn: the description in Chinese  
    Type: Number
    MinValue: 1
    Default: 10
  maxBandwidthOut:
    Label:
      en: The maximum public network bandwidth for out-direction
      zh-cn: the description in Chinese
    Description:
      en: <p>Unit: Mbit/s (Megabit per second). Value range: 0 to 100. OOS does not validate the maxBandwidthOut parameter value. <br/><font color='red'>If the value exceeded the limit of ECS, bandwidth upgrade task will fail. You can submit a ticket to ECS to raise the maximum bandwidth or modify the bandwidth parameter in limit range.</font></p>
      zh-cn: the description in Chinese  </font></p>
    Type: Number
    MinValue: 0
    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: 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 Cron expression
    zh-cn: the description in Chinese
  Properties:
    Type: cron
    Expression: '{{ triggerCron }}'
    EndDate: '{{ triggerEndDate }}'
    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: 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 }}'
      InternetMaxBandwidthIn: '{{ maxBandwidthIn }}'
      InternetMaxBandwidthOut: '{{ maxBandwidthOut }}'
      EndTime:
        Fn::FormatUTCTime:
          - Fn::AddHour:
              - '{{ ACS::CurrentUTCTime }}'
              - '{{ durationHour }}'
          - '%Y-%m-%dT%HZ'
  Loop:
    RateControl: '{{ rateControl }}'
    Items: '{{ getInstance.instanceIds }}'