alicloud_slb

Provides an Application Load Balancer resource.

Example Usage

# Create a new load balancer for classic
resource "alicloud_slb" "classic" {
  name                 = "test-slb-tf"
  internet             = true
  internet_charge_type = "paybybandwidth"
  bandwidth            = 5
  specification = "slb.s1.small"
}

# Create a new load balancer for VPC
resource "alicloud_vpc" "default" {
  # Other parameters...
}

resource "alicloud_vswitch" "default" {
  # Other parameters...
}

resource "alicloud_slb" "vpc" {
  name       = "test-slb-tf"
  vswitch_id = "${alicloud_vswitch.default.id}"
}

Argument Reference

The following arguments are supported:

  • name - (Optional) The name of the SLB. This name must be unique within your AliCloud account, can have a maximum of 80 characters, must contain only alphanumeric characters or hyphens, such as "-","/",".","_", and must not begin or end with a hyphen. If not specified, Terraform will autogenerate a name beginning with tf-lb.
  • internet - (Optional, Forces New Resource) If true, the SLB addressType will be internet, false will be intranet, Default is false. If load balancer launched in VPC, this value must be "false".
  • internet_charge_type - (Optional, Forces New Resource) Valid values are paybybandwidth, paybytraffic. If this value is "paybybandwidth", then argument "internet" must be "true". Default is "paybytraffic". If load balancer launched in VPC, this value must be "paybytraffic".
  • bandwidth - (Optional) Valid value is between 1 and 1000, If argument "internet_charge_type" is "paybytraffic", then this value will be ignore.
  • listener - (Deprecated) The field has been deprecated from terraform-alicloud-provider version 1.3.0, and use resource alicloud_slb_listener to replace.
  • vswitch_id - (Required for a VPC SLB, Forces New Resource) The VSwitch ID to launch in.
  • specification - (Optional) The specification of the Server Load Balancer instance. Default to empty string indicating it is "Shared-Performance" instance. Launching "Performance-guaranteed" instance, it is must be specified and it valid values are: "slb.s1.small", "slb.s2.small", "slb.s2.medium", "slb.s3.small", "slb.s3.medium" and "slb.s3.large".

Attributes Reference

The following attributes are exported:

  • id - The ID of the load balancer.
  • name - The name of the load balancer.
  • internet - The internet of the load balancer.
  • internet_charge_type - The internet_charge_type of the load balancer.
  • bandwidth - The bandwidth of the load balancer.
  • vswitch_id - The VSwitch ID of the load balancer. Only available on SLB launched in a VPC.
  • address - The IP address of the load balancer.
  • specification - The specification of the Server Load Balancer instance.

Import

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

$ terraform import alicloud_slb.example lb-abc123456

© 2018 HashiCorp
Licensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/alicloud/r/slb.html