Skip to content

alibabacloud-automation/terraform-alicloud-cen-cross-region-networking-with-qos

Repository files navigation

Terraform module to build refined traffic scheduling for cloud-based VPC cross-region connections for Alibaba Cloud

terraform-alicloud-cen-cross-region-networking-with-qos

English | 简体中文

This module focuses on scenarios involving refined traffic scheduling for cloud-based VPC cross-region connections. The total bandwidth for cross-region connections is fixed, and during the transmission of cross-region traffic, various business types often compete for bandwidth, leading to low network utilization and reduced quality of business communications. Different types of business traffic have varying network requirements, for example:

  • Core System Services (e.g., Video Conferencing and Voice Calls): These services prioritize real-time network transmission. High packet loss rates and frequent jitter can degrade communication quality.
  • Office SaaS and Other Services: These services emphasize timely responsiveness. Network congestion can diminish the user experience.
  • Offline Big Data Traffic: This traffic type prioritizes high network throughput and requires sufficient bandwidth, with less concern for network latency and jitter.

The traffic scheduling feature supports adding tags to different types of cross-region traffic and can impose bandwidth limits on each type based on these tags. This effectively ensures that each category of business has the necessary cross-region bandwidth, thereby improving the overall efficiency of the network. The overall solution is as follows:

  • Cloud Cross-Region: Utilize the Transit Router (TR) to establish a cross-region connection between Alibaba Cloud’s Beijing and Hangzhou regions. Concurrently, enable CDT (Cross-Region Traffic Billing) with bandwidth billed based on traffic, thereby linking the Beijing VPC with the Hangzhou VPC.
  • Cloud Cross-Domain Traffic Scheduling: Through the TR's cross-region traffic scheduling functionality, add tags to different types of cross-region traffic. Based on these tag values, apply bandwidth limits to each traffic type accordingly. This ensures that each category of business maintains its required cross-region bandwidth, enhancing the overall operational efficiency of the network.

Architecture Diagram:

Architecture Diagram

Usage

create VPCs in cn-beijing and cn-hangzhou.

provider "alicloud" {
  alias  = "local_region"
  region = "cn-beijing"
}

provider "alicloud" {
  alias  = "remote_region"
  region = "cn-hangzhou"
}


module "complete" {
  source = "alibabacloud-automation/cen-cross-region-networking-with-qos/alicloud"
  providers = {
    alicloud.local_region  = alicloud.local_region
    alicloud.remote_region = alicloud.remote_region
  }

  local_vpc_config = [{
    vpc = {
      vpc_name   = "beijing_vpc"
      cidr_block = "172.16.0.0/16"
    }
    vswitches = [{
      vswitch_name = "core System"
      zone_id      = "cn-beijing-j"
      cidr_block   = "172.16.10.0/24"
      }, {
      vswitch_name = "Others"
      zone_id      = "cn-beijing-k"
      cidr_block   = "172.16.20.0/24"
      }, {
      vswitch_name = "BigData"
      zone_id      = "cn-beijing-l"
      cidr_block   = "172.16.30.0/24"
    }]
  }]

  remote_vpc_config = [{
    vpc = {
      vpc_name   = "hangzhou_vpc"
      cidr_block = "192.168.0.0/16"
    }
    vswitches = [{
      vswitch_name = "vsw_j"
      zone_id      = "cn-hangzhou-j"
      cidr_block   = "192.168.1.0/24"
      }, {
      vswitch_name = "vsw_k"
      zone_id      = "cn-hangzhou-k"
      cidr_block   = "192.168.2.0/24"
    }]
  }]

  cen_traffic_marking_policys = [{
    marking_dscp = 10
    priority     = 10
    }, {
    marking_dscp = 20
    priority     = 20
  }]

  traffic_qos_policy_and_queues = {
    policy_name = "tf_example"
    queues = [{
      remain_bandwidth_percent = 40
      dscps                    = [10]
      queue_name               = "core"
      }, {
      remain_bandwidth_percent = 40
      dscps                    = [20]
      queue_name               = "bigdata"
    }]
  }
}

Examples

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
alicloud n/a
alicloud.local_region n/a
alicloud.remote_region n/a

Modules

Name Source Version
local_vpc ./modules/vpc n/a
remote_vpc ./modules/vpc n/a

Resources

Name Type
alicloud_cen_instance.this resource
alicloud_cen_inter_region_traffic_qos_policy.this resource
alicloud_cen_inter_region_traffic_qos_queue.this resource
alicloud_cen_traffic_marking_policy.this resource
alicloud_cen_transit_router.tr_local resource
alicloud_cen_transit_router.tr_remote resource
alicloud_cen_transit_router_peer_attachment.this resource
alicloud_cen_transit_router_route_table_association.tr_local resource
alicloud_cen_transit_router_route_table_association.tr_remote resource
alicloud_cen_transit_router_route_table_propagation.tr_local resource
alicloud_cen_transit_router_route_table_propagation.tr_remote resource
alicloud_cen_transit_router_route_tables.tr_local data source
alicloud_cen_transit_router_route_tables.tr_remote data source
alicloud_regions.remote data source

Inputs

Name Description Type Default Required
cen_instance_config The parameters of cen instance.
object({
cen_instance_name = optional(string, "cen-cross-region")
description = optional(string, "CEN instance for cross-region connectivity")
})
{} no
cen_traffic_marking_policys The parameters of cen traffic marking policies.
list(object({
marking_dscp = number
priority = number
traffic_marking_policy_name = optional(string, null)
}))
[] no
local_tr_config The parameters of transit router.
object({
transit_router_name = optional(string, "tr-local")
transit_router_description = optional(string, null)
})
{} no
local_vpc_config The parameters of local vpc resources. The attributes 'vpc', 'vswitches' are required.
list(object({
vpc = object({
cidr_block = string
vpc_name = optional(string, null)
})
vswitches = list(object({
zone_id = string
cidr_block = string
vswitch_name = optional(string, null)
}))
tr_vpc_attachment = optional(object({
transit_router_attachment_name = optional(string, null)
auto_publish_route_enabled = optional(bool, true)
route_table_propagation_enabled = optional(bool, true)
route_table_association_enabled = optional(bool, true)
}), {})
}))
[] no
remote_tr_config The parameters of transit router.
object({
transit_router_name = optional(string, "tr-remote")
transit_router_description = optional(string, null)
})
{} no
remote_vpc_config The parameters of remote vpc resources. The attributes 'vpc', 'vswitches' are required.
list(object({
vpc = object({
cidr_block = string
vpc_name = optional(string, null)
})
vswitches = list(object({
zone_id = string
cidr_block = string
vswitch_name = optional(string, null)
}))
tr_vpc_attachment = optional(object({
transit_router_attachment_name = optional(string, null)
auto_publish_route_enabled = optional(bool, true)
route_table_propagation_enabled = optional(bool, true)
route_table_association_enabled = optional(bool, true)
}), {})
}))
[] no
tr_peer_attachment The parameters of transit router peer attachment.
object({
transit_router_attachment_name = optional(string, null)
auto_publish_route_enabled = optional(bool, true)
route_table_propagation_enabled = optional(bool, true)
route_table_association_enabled = optional(bool, true)
bandwidth_type = optional(string, "DataTransfer")
bandwidth = optional(number, 100)
})
{} no
traffic_qos_policy_and_queues The parameters of cen inter region traffic qos policy and queues.
object({
policy_name = optional(string, null)
policy_description = optional(string, null)
queues = optional(list(object({
remain_bandwidth_percent = number
dscps = list(string)
queue_name = optional(string, null)
queue_description = optional(string, null)
})), [])
})
{} no

Outputs

Name Description
cen_instance_id The id of CEN instance.
cen_inter_region_traffic_qos_policy_id The id of cen inter region traffic qos policy.
cen_inter_region_traffic_qos_queue_ids The ids of cen inter region traffic qos queues.
cen_traffic_marking_policy_ids The ids of cen traffic marking policy.
local_cen_transit_router_id The id of local CEN transit router.
local_tr_vpc_attachment_id The id of attachment between TR and local VPC.
local_vpc_id The local vpc id.
local_vpc_route_table_id The route table id of local vpc.
local_vswitch_ids The local ids of vswitches.
remote_cen_transit_router_id The id of remote CEN transit router.
remote_tr_vpc_attachment_id The id of attachment between TR and remote VPC.
remote_vpc_id The remote vpc id.
remote_vpc_route_table_id The route table id of remote vpc.
remote_vswitch_ids The remote ids of vswitches.
tr_peer_attachment_id The id of attachment between local TR and remote TR.

Submit Issues

If you have any problems when using this module, please opening a provider issue and let us know.

Note: There does not recommend opening an issue on this repo.

Authors

Created and maintained by Alibaba Cloud Terraform Team([email protected]).

License

MIT Licensed. See LICENSE for full details.

Reference