alicloud_slb_load_balancer
Provides an Application Load Balancer resource.
-> NOTE: Available since v1.123.1.
-> NOTE: At present, to avoid some unnecessary regulation confusion, SLB can not support alicloud international account to create PayByBandwidth instance.
-> NOTE: The supported specifications vary by region. Currently, not all regions support guaranteed-performance instances. For more details about guaranteed-performance instance, see Guaranteed-performance instances.
Example Usage
# Create a intranet SLB instance
variable "slb_load_balancer_name" {
default = "forSlbLoadBalancer"
}
data "alicloud_zones" "load_balancer" {
available_resource_creation = "VSwitch"
}
resource "alicloud_vpc" "load_balancer" {
vpc_name = var.slb_load_balancer_name
}
resource "alicloud_vswitch" "load_balancer" {
vpc_id = alicloud_vpc.load_balancer.id
cidr_block = "172.16.0.0/21"
zone_id = data.alicloud_zones.load_balancer.zones[0].id
vswitch_name = var.slb_load_balancer_name
}
resource "alicloud_slb_load_balancer" "load_balancer" {
load_balancer_name = var.slb_load_balancer_name
address_type = "intranet"
load_balancer_spec = "slb.s2.small"
vswitch_id = alicloud_vswitch.load_balancer.id
tags = {
info = "create for internet"
}
instance_charge_type = "PayBySpec"
}
Deleting alicloud_slb_load_balancer or removing it from your configuration
The alicloud_slb_load_balancer resource allows you to manage payment_type = "Subscription" load balancer, but Terraform cannot destroy it.
Deleting the subscription resource or removing it from your configuration will remove it from your state file and management, but will not destroy the Load Balancer.
You can resume managing the subscription load balancer via the AlibabaCloud Console.
Argument Reference
The following arguments are supported:
load_balancer_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 withtf-lb.address_type- (Optional, ForceNew) The network type of the SLB instance. Valid values: ["internet", "intranet"]. If load balancer launched in VPC, this value must beintranet.- internet: After an Internet SLB instance is created, the system allocates a public IP address so that the instance can forward requests from the Internet.
- intranet: After an intranet SLB instance is created, the system allocates an intranet IP address so that the instance can only forward intranet requests.
internet_charge_type- (Optional) Valid values arePayByBandwidth,PayByTraffic. If this value isPayByBandwidth, then argumentaddress_typemust beinternet. Default isPayByTraffic. If load balancer launched in VPC, this value must bePayByTraffic. Before version 1.10.1, the valid values arepaybybandwidthandpaybytraffic.bandwidth- (Optional) Valid value is between 1 and 5120, If argumentinternet_charge_typeisPayByTraffic, then this value will be ignored.vswitch_id- (Optional, ForceNew) The VSwitch ID to launch in. Note: Required for a VPC SLB. Ifaddress_typeis internet, it will be ignored.load_balancer_spec- (Optional) The specification of the Server Load Balancer instance. Default to empty string indicating it is "Shared-Performance" instance. Launching "Performance-guaranteed" instance, it must be specified. Valid values:slb.s1.small,slb.s2.small,slb.s2.medium,slb.s3.small,slb.s3.medium,slb.s3.largeandslb.s4.large. It will be ignored wheninstance_charge_type = "PayByCLCU".tags- (Optional, Computed) A mapping of tags to assign to the resource. Thetagscan have a maximum of 10 tag for every load balancer instance. This filed mark asComputedsince v1.217.1.payment_type- (Optional) The billing method of the load balancer. Valid values arePayAsYouGoandSubscription. Default toPayAsYouGo.period- (Optional) The duration that you will buy the resource, in month. It is valid whenPaymentTypeisSubscription. Default to 1. Valid values: [1-9, 12, 24, 36]. This attribute is only used to createSubscriptioninstance or modify thePayAsYouGoinstance toSubscription. Once effect, it will not be modified that means runningterraform applywill not affect the resource.master_zone_id- (Optional, ForceNew) The primary zone ID of the SLB instance. If not specified, the system will be randomly assigned. You can query the primary and standby zones in a region by calling the DescribeZone API.slave_zone_id- (Optional, ForceNew) The standby zone ID of the SLB instance. If not specified, the system will be randomly assigned. You can query the primary and standby zones in a region by calling the DescribeZone API.delete_protection- (Optional) Whether enable the deletion protection or not. on: Enable deletion protection. off: Disable deletion protection. Default to off. Only postpaid instance support this function.address_ip_version- (Optional) The IP version of the SLB instance to be created, which can be set toipv4oripv6. Default toipv4. Now, only internet instance supportipv6address.address- (Optional) Specify the IP address of the private network for the SLB instance, which must be in the destination CIDR block of the corresponding switch.resource_group_id- (Optional, ForceNew) The id of resource group which the SLB belongs.modification_protection_reason- (Optional) The reason of modification protection. It's effective whenmodification_protection_statusisConsoleProtection.modification_protection_status- (Optional) The status of modification protection. Valid values:ConsoleProtectionandNonProtection. Default value isNonProtection.status- (Optional) The status of slb load balancer. Valid values:activeandinactice. The system default value isactive.name- (Optional, Deprecated from v1.123.1) Fieldnamehas been deprecated from provider version 1.123.1 New fieldload_balancer_nameinstead.instance_charge_type- (Optional, V1.193.0+) SupportPayBySpec(default) andPayByCLCU, This parameter takes effect when the value of payment_type (instance payment mode) is PayAsYouGo (pay-as-you-go).specification- (Optional, Deprecated from v1.123.1) Fieldspecificationhas been deprecated from provider version 1.123.1 New fieldload_balancer_specinstead.internet- (Optional, Deprecated from v1.124.0) Fieldinternethas been deprecated from provider version 1.124.0 New fieldaddress_typeinstead.
-> NOTE: A "Shared-Performance" instance can be changed to "Performance-guaranteed", but the change is irreversible.
-> NOTE: To change a "Shared-Performance" instance to a "Performance-guaranteed" instance, the SLB will have a short probability of business interruption (10 seconds-30 seconds). Advise to change it during the business downturn, or migrate business to other SLB Instances by using GSLB before changing.
-> NOTE: Currently, the alibaba cloud international account does not support creating a Subscription SLB instance.
-> NOTE: This parameter instance_charge_type is only valid for China sites and only if the payment_type value is PayAsYouGo.
Attributes Reference
The following attributes are exported:
id- The ID of the load balancer.address- The IP address of the load balancer.
Timeouts
The timeouts block allows you to specify timeouts for certain actions:
create- (Defaults to 5 mins) Used when creating the SLB load balancer.(until it reaches the initialactivestatus).delete- (Defaults to 9 mins) Used when terminating the SLB load balancer.
Import
Load balancer can be imported using the id, e.g.
$ terraform import alicloud_slb_load_balancer.example lb-abc123456