Create a LoadBalancer Resource.
resource "azurerm_resource_group" "test" { name = "LoadBalancerRG" location = "West US" } resource "azurerm_public_ip" "test" { name = "PublicIPForLB" location = "West US" resource_group_name = "${azurerm_resource_group.test.name}" public_ip_address_allocation = "static" } resource "azurerm_lb" "test" { name = "TestLoadBalancer" location = "West US" resource_group_name = "${azurerm_resource_group.test.name}" frontend_ip_configuration { name = "PublicIPAddress" public_ip_address_id = "${azurerm_public_ip.test.id}" } }
The following arguments are supported:
name
- (Required) Specifies the name of the LoadBalancer. resource_group_name
- (Required) The name of the resource group in which to create the LoadBalancer. location
- (Required) Specifies the supported Azure location where the resource exists. frontend_ip_configuration
- (Optional) A frontend ip configuration block as documented below. sku
- (Optional) The SKU of the Azure Load Balancer. Accepted values are Basic
and Standard
. Defaults to Basic
.
tags
- (Optional) A mapping of tags to assign to the resource.
frontend_ip_configuration
supports the following:
name
- (Required) Specifies the name of the frontend ip configuration. subnet_id
- (Optional) Reference to subnet associated with the IP Configuration. private_ip_address
- (Optional) Private IP Address to assign to the Load Balancer. The last one and first four IPs in any range are reserved and cannot be manually assigned. private_ip_address_allocation
- (Optional) Defines how a private IP address is assigned. Options are Static or Dynamic. public_ip_address_id
- (Optional) Reference to Public IP address to be associated with the Load Balancer. zones
- (Optional) A collection containing the availability zone to allocate the IP in. Please Note: Availability Zones are in Preview and only supported in several regions at this time - as such you must be opted into the Preview to use this functionality. You can opt into the Availability Zones Preview in the Azure Portal.
The following attributes are exported:
id
- The LoadBalancer ID. private_ip_address
- The first private IP address assigned to the load balancer in frontend_ip_configuration
blocks, if any. private_ip_addresses
- The list of private IP address assigned to the load balancer in frontend_ip_configuration
blocks, if any. Load Balancers can be imported using the resource id
, e.g.
terraform import azurerm_lb.test /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Network/loadBalancers/lb1
© 2018 HashiCorpLicensed under the MPL 2.0 License.
https://www.terraform.io/docs/providers/azurerm/r/loadbalancer.html