Load Balancer module can deploy these resources:
- azurerm_lb (required)
- azurerm_lb_backend_address_pool (optional)
- azurerm_lb_backend_address_pool_address (optional)
- azurerm_network_interface_backend_address_pool_association (optional)
- azurerm_lb_outbound_rule (optional)
- azurerm_lb_probe (optional)
- azurerm_lb_rule (optional)
- azurerm_lb_nat_rule (optional)
- azurerm_lb_nat_pool (optional)
- azurerm_monitor_diagnostic_setting (optional)
Example variables structure is located in variables.md.
Example use case is located in test-case/locals.tf.
You can also see changelog.
Terraform documentation:
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/lb
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/lb_outbound_rule
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/lb_probe
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/lb_rule
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/lb_nat_rule
https://registry.terraform.io/providers/hashicorp/azurerm/4.14.0/docs/resources/lb_nat_pool
WARNING: AzureRM provider had been updated to a new major version. Many breaking changes were implemented. See the providers guide for more information.
There are a few things you need to do to import resources into .tfstate. In the example below there are resources which can be imported within the module. You may need to modify these commands to the OS on which they will be running (Refer to the documentation for additional details).
- terraform import '
<path-to-module>
.azurerm_lb.lb["<lb-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_backend_address_pool.lb_backend_address_pool["<lb-name>
_<lb-backend-address-pool-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/backendAddressPools/<lb-backend-address-pool-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_backend_address_pool_address.lb_backend_address_pool_address["<lb-name>
_<lb-backend-address-pool-address-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/backendAddressPools/<lb-backend-address-pool-name>
/addresses/<lb-backend-address-pool-address-name>
'
- terraform import '
<path-to-module>
.azurerm_network_interface_backend_address_pool_association.network_interface_backend_address_pool_association["<lb-name>
_<network-interface-backend-address-pool-association-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/networkInterfaces/<network-interface-name>
/ipConfigurations/<ip-config-name>
|/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/backendAddressPools/<lb-backend-address-pool-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_outbound_rule.lb_outbound_rule["<lb-name>
_<lb-outbound-rule-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/outboundRules/<lb-outbound-rule-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_probe.lb_probe["<lb-name>
_<lb-probe-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/probes/<lb-probe-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_rule.lb_rule["<lb-name>
_<lb-rule-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/loadBalancingRules/<lb-rule-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_nat_rule.lb_nat_rule["<lb-name>
_<lb-nat-rule-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/inboundNatRules/<lb-nat-rule-name>
'
- terraform import '
<path-to-module>
.azurerm_lb_nat_pool.lb_nat_pool["<lb-name>
_<lb-nat-pool-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
/inboundNatPools/<lb-nat-pool-name>
'
- terraform import '
<path-to-module>
.azurerm_monitor_diagnostic_setting.diagnostic_setting["<lb-name>
_<diag-name>
"]' '/subscriptions/<subscription-id>
/resourceGroups/<resource-group-name>
/providers/Microsoft.Network/loadBalancers/<lb-name>
|<diag-name>
'
NOTE:
<path-to-module>
is terraform logical path from root. e.g. module.load_balancer
Output Name | Value | Comment |
---|---|---|
outputs | name | |
id | ||
backend_pools | Backend Address Pool outputs | |
id | ||
probes | Probe outputs | |
id | ||
nat_rules | NAT Rule outputs | |
id | ||
nat_pools | NAT Pool outputs | |
id |
In the example below, outputted id of the deployed Load Balancer module is used as a value for the scope variable in Role Assignment resource.
module "lb" {
source = "[email protected]:Seyfor-CSC/mit.load-balancer.git?ref=v1.0.0"
config = [
{
name = "SEY-TERRAFORM-NE-LB01"
location = "northeurope"
resource_group_name = "SEY-TERRAFORM-NE-RG01"
}
]
}
data "azurerm_client_config" "azurerm_client_config" {
}
resource "azurerm_role_assignment" "role_assignment" {
scope = module.lb.outputs.sey-terraform-ne-lb01.id # This is how to use output values
role_definition_name = "Contributor"
principal_id = data.azurerm_client_config.azurerm_client_config.object_id
}
backend_address_pool_names
replaces thebackend_address_pool_ids
variable in therules
list of objects.backend_address_pool_name
replaces thebackend_address_pool_id
variable in thenat_rules
list of objects.probe_name
replaces theprobe_id
variable in therules
list of objects.custom_name
used for looping through thenic_association
list of objects.
We currently log no issues in this module.