alicloud_slb_rule

Provides a Lindorm Instance resource.

For information about Load Balancer Forwarding Rule and how to use it, see What is Rule.

A forwarding rule is configured in HTTP/HTTPS listener and it used to listen a list of backend servers which in one specified virtual backend server group. You can add forwarding rules to a listener to forward requests based on the domain names or the URL in the request.

Example Usage

variable "slb_rule_name" {
  default = "terraform-example"
}

data "alicloud_zones" "rule" {
  available_resource_creation = "VSwitch"
}

resource "alicloud_vpc" "rule" {
  vpc_name   = var.slb_rule_name
  cidr_block = "172.16.0.0/16"
}

resource "alicloud_vswitch" "rule" {
  vpc_id       = alicloud_vpc.rule.id
  cidr_block   = "172.16.0.0/16"
  zone_id      = data.alicloud_zones.rule.zones[0].id
  vswitch_name = var.slb_rule_name
}

resource "alicloud_slb_load_balancer" "rule" {
  load_balancer_name   = var.slb_rule_name
  vswitch_id           = alicloud_vswitch.rule.id
  instance_charge_type = "PayByCLCU"
}

resource "alicloud_slb_listener" "rule" {
  load_balancer_id          = alicloud_slb_load_balancer.rule.id
  backend_port              = 22
  frontend_port             = 22
  protocol                  = "http"
  bandwidth                 = 5
  health_check_connect_port = "20"
}

resource "alicloud_slb_server_group" "rule" {
  load_balancer_id = alicloud_slb_load_balancer.rule.id
  name             = var.slb_rule_name
}

resource "alicloud_slb_rule" "rule" {
  load_balancer_id          = alicloud_slb_load_balancer.rule.id
  frontend_port             = alicloud_slb_listener.rule.frontend_port
  name                      = var.slb_rule_name
  domain                    = "*.aliyun.com"
  url                       = "/image"
  server_group_id           = alicloud_slb_server_group.rule.id
  cookie                    = "23ffsa"
  cookie_timeout            = 100
  health_check_http_code    = "http_2xx"
  health_check_interval     = 10
  health_check_uri          = "/test"
  health_check_connect_port = 80
  health_check_timeout      = 30
  healthy_threshold         = 3
  unhealthy_threshold       = 5
  sticky_session            = "on"
  sticky_session_type       = "server"
  listener_sync             = "off"
  scheduler                 = "rr"
  health_check_domain       = "test"
  health_check              = "on"
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Load balancer forwarding rule can be imported using the id, e.g.

$ terraform import alicloud_slb_rule.example <id>