Skip to content

alibabacloud-automation/terraform-alicloud-add-on-premises-servers-to-alb

Repository files navigation

Terraform module to add on-premises servers to ALB for Alibaba Cloud

terraform-alicloud-add-on-premises-servers-to-alb

English | 简体中文

This Module designs a cloud-based delivery network for IDC seven-layer applications, including:

  1. Building a high-availability dedicated network between the cloud and IDC through ECR (Express Connect Router)
  2. Enabling the migration of seven-layer public network entry points of IDC servers to the cloud through ALB (Application Load Balancer).

Architecture Diagram:

Architecture Diagram

Usage

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

data "alicloud_express_connect_physical_connections" "example" {
  name_regex = "^preserved-NODELETING"
}

module "complete" {
  source = "alibabacloud-automation/add-on-premises-servers-to-alb/alicloud"

  vpc_config = {
    cidr_block = "10.0.0.0/16"
  }
  vswitches  = [{
    zone_id    = "cn-hangzhou-i"
    cidr_block = "10.0.1.0/24"
    }, {
    zone_id    = "cn-hangzhou-j"
    cidr_block = "10.0.2.0/24"
  }]

  alb_server_group = {
    server_group_name = "idc"
    servers = [{
      server_type       = "Ip"
      server_id         = "172.16.1.5"
      server_ip         = "172.16.1.5"
      weight            = 10
      port              = 80
      remote_ip_enabled = true
    }]
  }

  ecr_alibaba_side_asn = 64512

  vbr_config = [
    {
      physical_connection_id = data.alicloud_express_connect_physical_connections.example.connections[0].id
      vlan_id                = 104
      local_gateway_ip       = "192.168.0.1"
      peer_gateway_ip        = "192.168.0.2"
      peering_subnet_mask    = "255.255.255.252"
    },
    {
      physical_connection_id = data.alicloud_express_connect_physical_connections.example.connections[1].id
      vlan_id                = 105
      local_gateway_ip       = "192.168.1.1"
      peer_gateway_ip        = "192.168.1.2"
      peering_subnet_mask    = "255.255.255.252"
    }
  ]

  vbr_bgp_group = {
    peer_asn = 45000
  }

  tags = {
    "Created" = "Terraform"
  }
}

Examples

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
alicloud n/a

Modules

No modules.

Resources

Name Type
alicloud_alb_listener.this resource
alicloud_alb_load_balancer.this resource
alicloud_alb_server_group.this resource
alicloud_express_connect_router_express_connect_router.this resource
alicloud_express_connect_router_vbr_child_instance.this resource
alicloud_express_connect_router_vpc_association.this resource
alicloud_express_connect_virtual_border_router.this resource
alicloud_vpc.this resource
alicloud_vpc_bgp_group.this resource
alicloud_vpc_bgp_peer.this resource
alicloud_vswitch.this resource
alicloud_regions.default data source

Inputs

Name Description Type Default Required
alb_listener The parameters of alb listener.
object({
listener_protocol = string
listener_port = number
})
{
"listener_port": 80,
"listener_protocol": "HTTP"
}
no
alb_load_balancer The parameters of alb load balancer.
object({
load_balancer_edition = string
pay_type = optional(string, "PayAsYouGo")
modification_protection_config = optional(object({
status = optional(string, "NonProtection")
reason = optional(string, null)
}), {})
})
{
"load_balancer_edition": "Standard"
}
no
alb_server_group The parameters of alb server group.
object({
server_group_name = string
scheduler = optional(string, "Wrr")
protocol = optional(string, "HTTP")
sticky_session_config = optional(object({
sticky_session_enabled = optional(bool, true)
cookie = optional(string, "tf-example")
sticky_session_type = optional(string, "Server")
}), {})
health_check_config = optional(object({
health_check_enabled = optional(bool, true)
health_check_connect_port = optional(number, 46325)
health_check_host = optional(string, "tf-example.com")
health_check_codes = optional(list(string), ["http_2xx", "http_3xx", "http_4xx"])
health_check_http_version = optional(string, "HTTP1.1")
health_check_interval = optional(number, 2)
health_check_method = optional(string, "HEAD")
health_check_path = optional(string, "/tf-example")
health_check_protocol = optional(string, "HTTP")
health_check_timeout = optional(number, 5)
healthy_threshold = optional(number, 3)
unhealthy_threshold = optional(number, 3)
}), {})
servers = optional(list(object({
server_type = string
server_id = string
server_ip = optional(string, null)
weight = optional(number, null)
port = optional(number, null)
remote_ip_enabled = optional(bool, null)
})), [])
})
{
"server_group_name": "idc_server_group"
}
no
ecr_alibaba_side_asn The alibaba side asn for ECR. number null no
resource_group_id The resource group id. string null no
tags The tags of resources. map(string) {} no
vbr_bgp_group The parameters of the bgp group. The attribute 'peer_asn' is required.
object({
peer_asn = string
auth_key = optional(string, null)
bgp_group_name = optional(string, null)
description = optional(string, null)
is_fake_asn = optional(bool, false)
})
{
"peer_asn": null
}
no
vbr_bgp_peer The parameters of the bgp peer. The default value of 'bfd_multi_hop' is 255. The default value of 'enable_bfd' is 'false'. The default value of 'ip_version' is 'IPV4'.
object({
bfd_multi_hop = optional(number, 10)
enable_bfd = optional(bool, "true")
ip_version = optional(string, "IPV4")
peer_ip_address = optional(string, null)
})
{} no
vbr_config The list parameters of VBR. The attributes 'physical_connection_id', 'vlan_id', 'local_gateway_ip','peer_gateway_ip','peering_subnet_mask' are required.
list(object({
physical_connection_id = string
vlan_id = number
local_gateway_ip = string
peer_gateway_ip = string
peering_subnet_mask = string
virtual_border_router_name = optional(string, null)
description = optional(string, null)
}))
[
{
"local_gateway_ip": null,
"peer_gateway_ip": null,
"peering_subnet_mask": null,
"physical_connection_id": null,
"vlan_id": null
},
{
"local_gateway_ip": null,
"peer_gateway_ip": null,
"peering_subnet_mask": null,
"physical_connection_id": null,
"vlan_id": null
}
]
no
vpc_config The parameters of vpc. The attribute 'cidr_block' is required.
object({
cidr_block = string
vpc_name = optional(string, null)
enable_ipv6 = optional(bool, null)
})
{
"cidr_block": null
}
no
vswitches The parameters of vswitches. The attributes 'zone_id', 'cidr_block' are required.
list(object({
zone_id = string
cidr_block = string
vswitch_name = optional(string, null)
}))
[
{
"cidr_block": null,
"zone_id": null
},
{
"cidr_block": null,
"zone_id": null
}
]
no

Outputs

Name Description
alb_listener The ID of the ALB Listener.
alb_load_balancer_id The ID of the ALB Load Balancer.
alb_server_group_id The ID of the ALB Server Group.
bgp_group_id The id of BGP group.
bgp_peer_id The id of BGP peer.
ecr_id The id of Express Connect Router.
ecr_vpc_association_id The association ID of Express Connect Router and VPC.
vbr_id The id of VBR.
vpc_id The ID of the VPC.
vswitch_ids The IDs of the VSwitches.

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