diff --git a/modules/vmss_existing_vnet/README.md b/modules/vmss_existing_vnet/README.md
index ec3a871..6ea6307 100755
--- a/modules/vmss_existing_vnet/README.md
+++ b/modules/vmss_existing_vnet/README.md
@@ -49,6 +49,7 @@ module "example_module" {
availability_zones_num = "1"
minimum_number_of_vm_instances = 2
maximum_number_of_vm_instances = 10
+ number_of_vm_instances = 2
management_name = "mgmt"
management_IP = "13.92.42.181"
management_interface = "eth1-private"
@@ -108,6 +109,7 @@ module "example_module" {
| **availability_zones_num** | A list of a single item of the Availability Zone which the Virtual Machine should be allocated in | string | "centralus", "eastus2", "francecentral", "northeurope", "southeastasia", "westeurope", "westus2", "eastus", "uksouth". |
| **minimum_number_of_vm_instances** | The minimum number of VMSS instances for this resource | number | Valid values are in the range 0 - 10. |
| **maximum_number_of_vm_instances** | The maximum number of VMSS instances for this resource | number | Valid values are in the range 0 - 10. |
+| **number_of_vm_instances** | The default number of VMSS instances to deploy. | number | The number of VMSS instances must not be less then `minimum_number_of_vm_instances`. If the number of VMSS is greater then the `maximum_number_of_vm_instances` use the maximum number as default.
**Default**: 2; |
| **management_name** | The name of the management server as it appears in the configuration file | string | Field cannot be empty. Only alphanumeric characters or '_'/'-' are allowed, and the name must be 1-30 characters long. |
| **management_IP** | The IP address used to manage the VMSS instances | string | A valid IP address. |
| **management_interface** | Management option for the Gateways in the VMSS | string | "eth0-public" - Manages the GWs using their external NIC's public IP address;
"eth0-private" - Manages the GWs using their external NIC's private IP address;
"eth1-private" - Manages the GWs using their internal NIC's private IP address.
**Default:** "eth1-private" |
diff --git a/modules/vmss_existing_vnet/locals.tf b/modules/vmss_existing_vnet/locals.tf
index f391758..302d292 100755
--- a/modules/vmss_existing_vnet/locals.tf
+++ b/modules/vmss_existing_vnet/locals.tf
@@ -1,4 +1,20 @@
locals {
module_name = "vmss_terraform_registry"
module_version = "1.0.5"
+
+ // Validate that the minimum number of VM instances is at least 0.
+ // If not, return an error message.
+ validate_number_of_vm_instances_range = var.minimum_number_of_vm_instances >= 0 && var.maximum_number_of_vm_instances >= 0 ? 0 : index("error: The minimum and maximum number of VM instances must be at least 0.")
+
+ // Validate that the maximum number of VM instances is greater than or equal to the minimum number of VM instances.
+ // If not, return an error message.
+ validate_maximum_number_of_vm_instances = var.maximum_number_of_vm_instances >= var.minimum_number_of_vm_instances ? 0 : index("error: The maximum number of VM instances must be greater than or equal to the minimum number of VM instances.")
+
+ // The number of VM instances should not exceed the maximum allowed.
+ // If the provided number of instances exceeds the maximum, use the maximum instead.
+ number_of_vm_instances = var.maximum_number_of_vm_instances >= var.number_of_vm_instances ? var.number_of_vm_instances : var.maximum_number_of_vm_instances
+
+ // Validate the number of VM instances against the minimum requirement.
+ // If the number of instances is less than the minimum, return an error message.
+ validate_number_of_vm_instances = local.number_of_vm_instances >= var.minimum_number_of_vm_instances? 0 : index("error: The number of VM instances must be at least ${var.minimum_number_of_vm_instances}.")
}
diff --git a/modules/vmss_existing_vnet/main.tf b/modules/vmss_existing_vnet/main.tf
index 548b8bc..4a7352f 100755
--- a/modules/vmss_existing_vnet/main.tf
+++ b/modules/vmss_existing_vnet/main.tf
@@ -7,7 +7,7 @@ module "common" {
installation_type = var.installation_type
module_name = local.module_name
module_version = local.module_version
- number_of_vm_instances = var.number_of_vm_instances
+ number_of_vm_instances = local.number_of_vm_instances
allow_upload_download = var.allow_upload_download
vm_size = var.vm_size
disk_size = var.disk_size
@@ -217,7 +217,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "vmss" {
resource_group_name = module.common.resource_group_name
sku = module.common.vm_size
zones = local.availability_zones_num_condition
- instances = var.number_of_vm_instances
+ instances = local.number_of_vm_instances
overprovision = false
dynamic "identity" {
diff --git a/modules/vmss_new_vnet/README.md b/modules/vmss_new_vnet/README.md
index 35a8320..578a95f 100755
--- a/modules/vmss_new_vnet/README.md
+++ b/modules/vmss_new_vnet/README.md
@@ -53,6 +53,7 @@ module "example_module" {
availability_zones_num = "1"
minimum_number_of_vm_instances = 2
maximum_number_of_vm_instances = 10
+ number_of_vm_instances = 2
management_name = "mgmt"
management_IP = "13.92.42.181"
management_interface = "eth1-private"
@@ -105,8 +106,9 @@ module "example_module" {
| **allow_upload_download** | Automatically download Blade Contracts and other important data. Improve product experience by sending data to Check Point | boolean | true;
false;
|
| **authentication_type** | Specifies whether a password authentication or SSH Public Key authentication should be used | string | "Password";
"SSH Public Key";
|
| **availability_zones_num** | A list of a single item of the Availability Zone where the Virtual Machine should be allocated | string | "centralus", "eastus2", "francecentral", "northeurope", "southeastasia", "westeurope", "westus2", "eastus", "uksouth"
|
-| **minimum_number_of_vm_instances** | The minimum number of VMSS instances for this resource | number | Valid values are in the range 0 - 10
|
-| **maximum_number_of_vm_instances** | The maximum number of VMSS instances for this resource | number | Valid values are in the range 0 - 10
|
+| **minimum_number_of_vm_instances** | The minimum number of VMSS instances for this resource. | number | Valid values are in the range 0 - 10
|
+| **maximum_number_of_vm_instances** | The maximum number of VMSS instances for this resource. | number | Valid values are in the range 0 - 10
|
+| **number_of_vm_instances** | The default number of VMSS instances to deploy. | number | The number of VMSS instances must not be less then `minimum_number_of_vm_instances`. If the number of VMSS is greater then the `maximum_number_of_vm_instances` use the maximum number by default.
**Default**: 2; |
| **management_name** | The name of the management server as it appears in the configuration file | string | Field cannot be empty. Only alphanumeric characters or '_'/'-' are allowed, and the name must be 1-30 characters long
|
| **management_IP** | The IP address used to manage the VMSS instances | string | A valid IP address
|
| **management_interface** | Management option for the Gateways in the VMSS | string | "eth0-public" - Manages the GWs using their external NIC's public IP address;
"eth0-private" - Manages the GWs using their external NIC's private IP address;
"eth1-private" - Manages the GWs using their internal NIC's private IP address;
**Default:** "eth1-private" |
diff --git a/modules/vmss_new_vnet/locals.tf b/modules/vmss_new_vnet/locals.tf
index f391758..302d292 100755
--- a/modules/vmss_new_vnet/locals.tf
+++ b/modules/vmss_new_vnet/locals.tf
@@ -1,4 +1,20 @@
locals {
module_name = "vmss_terraform_registry"
module_version = "1.0.5"
+
+ // Validate that the minimum number of VM instances is at least 0.
+ // If not, return an error message.
+ validate_number_of_vm_instances_range = var.minimum_number_of_vm_instances >= 0 && var.maximum_number_of_vm_instances >= 0 ? 0 : index("error: The minimum and maximum number of VM instances must be at least 0.")
+
+ // Validate that the maximum number of VM instances is greater than or equal to the minimum number of VM instances.
+ // If not, return an error message.
+ validate_maximum_number_of_vm_instances = var.maximum_number_of_vm_instances >= var.minimum_number_of_vm_instances ? 0 : index("error: The maximum number of VM instances must be greater than or equal to the minimum number of VM instances.")
+
+ // The number of VM instances should not exceed the maximum allowed.
+ // If the provided number of instances exceeds the maximum, use the maximum instead.
+ number_of_vm_instances = var.maximum_number_of_vm_instances >= var.number_of_vm_instances ? var.number_of_vm_instances : var.maximum_number_of_vm_instances
+
+ // Validate the number of VM instances against the minimum requirement.
+ // If the number of instances is less than the minimum, return an error message.
+ validate_number_of_vm_instances = local.number_of_vm_instances >= var.minimum_number_of_vm_instances? 0 : index("error: The number of VM instances must be at least ${var.minimum_number_of_vm_instances}.")
}
diff --git a/modules/vmss_new_vnet/main.tf b/modules/vmss_new_vnet/main.tf
index 559c27a..d365acc 100755
--- a/modules/vmss_new_vnet/main.tf
+++ b/modules/vmss_new_vnet/main.tf
@@ -7,7 +7,7 @@ module "common" {
installation_type = var.installation_type
module_name = local.module_name
module_version = local.module_version
- number_of_vm_instances = var.number_of_vm_instances
+ number_of_vm_instances = local.number_of_vm_instances
allow_upload_download = var.allow_upload_download
vm_size = var.vm_size
disk_size = var.disk_size
@@ -213,7 +213,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "vmss" {
resource_group_name = module.common.resource_group_name
sku = module.common.vm_size
zones = local.availability_zones_num_condition
- instances = var.number_of_vm_instances
+ instances = local.number_of_vm_instances
overprovision = false
dynamic "identity" {