F5Networks / terraform-azure-bigip-module

Terraform module for Deploying BIG-IP in azure
Apache License 2.0
9 stars 24 forks source link

User wants to set VM name - currently name is forced #49

Closed JeffGiroux closed 1 year ago

JeffGiroux commented 1 year ago

User has requirement to set VM name to match their naming standards. Currently the Azure BIG-IP module is forcing the 'name' and 'computer_name' field to a fixed name. Please allow user to supply a vm_name input parameter similar to the GCP BIG-IP module.

Code in reference...

# Create F5 BIGIP1
resource "azurerm_linux_virtual_machine" "f5vm01" {
  name                            = "${local.instance_prefix}-f5vm01"
  location                        = data.azurerm_resource_group.bigiprg.location
  resource_group_name             = data.azurerm_resource_group.bigiprg.name
  network_interface_ids           = concat(azurerm_network_interface.mgmt_nic.*.id, azurerm_network_interface.external_nic.*.id, azurerm_network_interface.external_public_nic.*.id, azurerm_network_interface.internal_nic.*.id)
  size                            = var.f5_instance_type
  disable_password_authentication = var.enable_ssh_key
  computer_name                   = "${local.instance_prefix}-f5vm01"

Suggestion

Have some type of if/then logic to check if user supplied vm_name exists, if so...use it. If not, use dynamic name similar to prefix+bigip01 or other. Give results to 'name'.

For API reference, only 'name' is required versus both 'name' and 'computer_name'. If 'computer_name' is supplied, then it is used over 'name'. Since you are setting both parameters to the same value, you might simplify code by removing 'computer_name'.

JeffGiroux commented 1 year ago

example in GCP bigip module https://github.com/F5Networks/terraform-gcp-bigip-module/blob/7152cbcf93102f02599b39608362bb6917aec4e8/main.tf

resource "google_compute_instance" "f5vm01" {
  name = var.vm_name == "" ? format("%s", local.instance_prefix) : var.vm_name