Skip to content

Commit

Permalink
Azure Terraform | Update availability_zones_num variable to use numbe…
Browse files Browse the repository at this point in the history
…r type
  • Loading branch information
chkp-natanelm committed Jan 14, 2025
1 parent a5afa77 commit 788ceeb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 36 deletions.
2 changes: 1 addition & 1 deletion terraform/azure/vmss-existing-vnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ This solution uses the following modules:
| | | | | |
| **authentication_type** | Specifies whether a password authentication or SSH Public Key authentication should be used | string | "Password"; <br/>"SSH Public Key"; | n/a
| | | | | |
| **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" | n/a
| **availability_zones_num** | The number of availability zones to use for Scale Set. Note that the load balancers and their IP addresses will be redundant in any case. [List of Azure regions with availability zone support](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-region-support) | number | 0 </br> 1</br> 2</br> 3 | n/a
| | | | | |
| **minimum_number_of_vm_instances** | The minimum number of VMSS instances for this resource | number | Valid values are in the range 0 - 10 | n/a
| | | | | |
Expand Down
2 changes: 1 addition & 1 deletion terraform/azure/vmss-existing-vnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ resource "azurerm_storage_account" "vm-boot-diagnostics-storage" {
//********************** Virtual Machines **************************//
locals {
SSH_authentication_type_condition = var.authentication_type == "SSH Public Key" ? true : false
availability_zones_num_condition = var.availability_zones_num == "0" ? null : var.availability_zones_num == "1" ? ["1"] : var.availability_zones_num == "2" ? ["1", "2"] : ["1", "2", "3"]
availability_zones_num_condition = var.availability_zones_num == 0 ? null : var.availability_zones_num == 1 ? ["1"] : var.availability_zones_num == 2 ? ["1", "2"] : ["1", "2", "3"]
custom_image_condition = var.source_image_vhd_uri == "noCustomUri" ? false : true
management_interface_name = split("-", var.management_interface)[0]
management_ip_address_type = split("-", var.management_interface)[1]
Expand Down
2 changes: 1 addition & 1 deletion terraform/azure/vmss-existing-vnet/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ os_version = "PLEASE ENTER GAIA OS VERSION"
bootstrap_script = "PLEASE ENTER CUSTOM SCRIPT OR LEAVE EMPTY DOUBLE QUOTES" # "touch /home/admin/bootstrap.txt; echo 'hello_world' > /home/admin/bootstrap.txt"
allow_upload_download = "PLEASE ENTER true or false" # true
authentication_type = "PLEASE ENTER AUTHENTICATION TYPE" # "Password"
availability_zones_num = "PLEASE ENTER NUMBER OF AVAILABILITY ZONES" # "1"
availability_zones_num = "PLEASE ENTER NUMBER OF AVAILABILITY ZONES" # 1
minimum_number_of_vm_instances = "PLEASE ENTER MINIMUM NUMBER OF VM INSTANCES" # 2
maximum_number_of_vm_instances = "PLEASE ENTER MAXIMUM NUMBER OF VM INSTANCES" # 10
management_name = "PLEASE ENTER MANAGEMENT NAME" # "mgmt"
Expand Down
21 changes: 6 additions & 15 deletions terraform/azure/vmss-existing-vnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,12 @@ variable "maintenance_mode_password_hash" {
}

variable "availability_zones_num" {
description = "The number of availability zones to use for Scale Set. Note that the load balancers and their IP addresses will be redundant in any case"
#Availability Zones are only supported in several regions at this time
#"centralus", "eastus2", "francecentral", "northeurope", "southeastasia", "westeurope", "westus2", "eastus", "uksouth"
#type = list(string)
}

locals { // locals for 'availability_zones_num' allowed values
availability_zones_num_allowed_values = [
"0",
"1",
"2",
"3"
]
// will fail if [var.availability_zones_num] is invalid:
validate_availability_zones_num_value = index(local.availability_zones_num_allowed_values, var.availability_zones_num)
description = "The number of availability zones to use for Scale Set. Note that the load balancers and their IP addresses will be redundant in any case."
type = number
validation {
condition = contains([0, 1, 2, 3], var.availability_zones_num)
error_message = "The availability_zones_num must be one of the following values: 0, 1, 2, 3."
}
}

variable "sic_key" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/azure/vmss-new-vnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ This solution uses the following modules:
| | | | | |
| **authentication_type** | Specifies whether a password authentication or SSH Public Key authentication should be used | string | "Password"; <br/>"SSH Public Key"; | n/a
| | | | | |
| **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" | n/a
| **availability_zones_num** | The number of availability zones to use for Scale Set. Note that the load balancers and their IP addresses will be redundant in any case. [List of Azure regions with availability zone support](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-region-support) | number | 0 </br> 1</br> 2</br> 3 | n/a
| | | | | |
| **minimum_number_of_vm_instances** | The minimum number of VMSS instances for this resource | number | Valid values are in the range 0 - 10 | n/a
| | | | | |
Expand Down
2 changes: 1 addition & 1 deletion terraform/azure/vmss-new-vnet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ resource "azurerm_storage_account" "vm-boot-diagnostics-storage" {
//********************** Virtual Machines **************************//
locals {
SSH_authentication_type_condition = var.authentication_type == "SSH Public Key" ? true : false
availability_zones_num_condition = var.availability_zones_num == "0" ? null : var.availability_zones_num == "1" ? ["1"] : var.availability_zones_num == "2" ? ["1", "2"] : ["1", "2", "3"]
availability_zones_num_condition = var.availability_zones_num == 0 ? null : var.availability_zones_num == 1 ? ["1"] : var.availability_zones_num == 2 ? ["1", "2"] : ["1", "2", "3"]
custom_image_condition = var.source_image_vhd_uri == "noCustomUri" ? false : true
management_interface_name = split("-", var.management_interface)[0]
management_ip_address_type = split("-", var.management_interface)[1]
Expand Down
2 changes: 1 addition & 1 deletion terraform/azure/vmss-new-vnet/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ os_version = "PLEASE ENTER GAIA OS VERSION"
bootstrap_script = "PLEASE ENTER CUSTOM SCRIPT OR LEAVE EMPTY DOUBLE QUOTES" # "touch /home/admin/bootstrap.txt; echo 'hello_world' > /home/admin/bootstrap.txt"
allow_upload_download = "PLEASE ENTER true or false" # true
authentication_type = "PLEASE ENTER AUTHENTICATION TYPE" # "Password"
availability_zones_num = "PLEASE ENTER NUMBER OF AVAILABILITY ZONES" # "1"
availability_zones_num = "PLEASE ENTER NUMBER OF AVAILABILITY ZONES" # 1
minimum_number_of_vm_instances = "PLEASE ENTER MINIMUM NUMBER OF VM INSTANCES" # 2
maximum_number_of_vm_instances = "PLEASE ENTER MAXIMUM NUMBER OF VM INSTANCES" # 10
management_name = "PLEASE ENTER MANAGEMENT NAME" # "mgmt"
Expand Down
21 changes: 6 additions & 15 deletions terraform/azure/vmss-new-vnet/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,12 @@ variable "maintenance_mode_password_hash" {
}

variable "availability_zones_num" {
description = "The number of availability zones to use for Scale Set. Note that the load balancers and their IP addresses will be redundant in any case"
#Availability Zones are only supported in several regions at this time
#"centralus", "eastus2", "francecentral", "northeurope", "southeastasia", "westeurope", "westus2", "eastus", "uksouth"
#type = list(string)
}

locals { // locals for 'availability_zones_num' allowed values
availability_zones_num_allowed_values = [
"0",
"1",
"2",
"3"
]
// will fail if [var.availability_zones_num] is invalid:
validate_availability_zones_num_value = index(local.availability_zones_num_allowed_values, var.availability_zones_num)
description = "The number of availability zones to use for Scale Set. Note that the load balancers and their IP addresses will be redundant in any case."
type = number
validation {
condition = contains([0, 1, 2, 3], var.availability_zones_num)
error_message = "The availability_zones_num must be one of the following values: 0, 1, 2, 3."
}
}

variable "sic_key" {
Expand Down

0 comments on commit 788ceeb

Please sign in to comment.