From 321f426cc0df6333026057a37db9fd80f607ae38 Mon Sep 17 00:00:00 2001 From: Michele Pagot Date: Tue, 3 Sep 2024 09:12:15 +0200 Subject: [PATCH] Use vm_size in AWS modules Try to use a uniform naming convention for modules across different cloud providers. This commit intentionally only change internal modules API and does not touch `terraform/aws/variables.tf`. In this way the end user has not to change anything in the conf.yaml. Remove some vm_size default at module level, only to have defaults in the upper layer and in a single place. Reorder variables fields always to have description at first place. --- terraform/aws/main.tf | 10 ++++---- terraform/aws/modules/drbd_node/main.tf | 2 +- terraform/aws/modules/drbd_node/variables.tf | 15 ++++++------ terraform/aws/modules/hana_node/main.tf | 2 +- terraform/aws/modules/hana_node/variables.tf | 5 ++-- terraform/aws/modules/iscsi_server/main.tf | 2 +- .../aws/modules/iscsi_server/variables.tf | 2 +- terraform/aws/modules/monitoring/main.tf | 2 +- terraform/aws/modules/monitoring/variables.tf | 11 +++++---- terraform/aws/modules/netweaver_node/main.tf | 2 +- .../aws/modules/netweaver_node/variables.tf | 21 +++++++++-------- .../azure/modules/drbd_node/variables.tf | 23 +++++++++++-------- .../azure/modules/hana_node/variables.tf | 3 ++- 13 files changed, 54 insertions(+), 46 deletions(-) diff --git a/terraform/aws/main.tf b/terraform/aws/main.tf index 17bb3f09..dc7e06d3 100644 --- a/terraform/aws/main.tf +++ b/terraform/aws/main.tf @@ -137,7 +137,7 @@ module "drbd_node" { name = var.drbd_name network_domain = var.drbd_network_domain == "" ? var.network_domain : var.drbd_network_domain drbd_count = var.drbd_enabled == true ? 2 : 0 - instance_type = var.drbd_instancetype + vm_size = var.drbd_instancetype availability_zones = data.aws_availability_zones.available.names os_image = local.drbd_os_image os_owner = local.drbd_os_owner @@ -167,7 +167,7 @@ module "iscsi_server" { subnet_ids = aws_subnet.infra-subnet.*.id os_image = local.iscsi_os_image os_owner = local.iscsi_os_owner - instance_type = var.iscsi_instancetype + vm_size = var.iscsi_instancetype key_name = aws_key_pair.key-pair.key_name security_group_id = local.security_group_id host_ips = local.iscsi_ips @@ -182,7 +182,7 @@ module "netweaver_node" { network_domain = var.netweaver_network_domain == "" ? var.network_domain : var.netweaver_network_domain xscs_server_count = local.netweaver_xscs_server_count app_server_count = var.netweaver_enabled ? var.netweaver_app_server_count : 0 - instance_type = var.netweaver_instancetype + vm_size = var.netweaver_instancetype availability_zones = data.aws_availability_zones.available.names os_image = local.netweaver_os_image os_owner = local.netweaver_os_owner @@ -207,7 +207,7 @@ module "hana_node" { name = var.hana_name network_domain = var.hana_network_domain == "" ? var.network_domain : var.hana_network_domain hana_count = var.hana_count - instance_type = var.hana_instancetype + vm_size = var.hana_instancetype availability_zones = data.aws_availability_zones.available.names os_image = local.hana_os_image os_owner = local.hana_os_owner @@ -231,7 +231,7 @@ module "monitoring" { name = var.monitoring_name network_domain = var.monitoring_network_domain == "" ? var.network_domain : var.monitoring_network_domain monitoring_enabled = var.monitoring_enabled - instance_type = var.monitor_instancetype + vm_size = var.monitor_instancetype key_name = aws_key_pair.key-pair.key_name security_group_id = local.security_group_id monitoring_srv_ip = local.monitoring_ip diff --git a/terraform/aws/modules/drbd_node/main.tf b/terraform/aws/modules/drbd_node/main.tf index fd69866c..8d8c8f59 100644 --- a/terraform/aws/modules/drbd_node/main.tf +++ b/terraform/aws/modules/drbd_node/main.tf @@ -38,7 +38,7 @@ module "get_os_image" { resource "aws_instance" "drbd" { count = var.drbd_count ami = module.get_os_image.image_id - instance_type = var.instance_type + instance_type = var.vm_size key_name = var.key_name associate_public_ip_address = true subnet_id = element(aws_subnet.drbd-subnet.*.id, count.index) diff --git a/terraform/aws/modules/drbd_node/variables.tf b/terraform/aws/modules/drbd_node/variables.tf index e95a632a..32a5a8b5 100644 --- a/terraform/aws/modules/drbd_node/variables.tf +++ b/terraform/aws/modules/drbd_node/variables.tf @@ -18,40 +18,39 @@ variable "drbd_count" { default = 2 } -variable "instance_type" { +variable "vm_size" { description = "The instance type of drbd node" type = string - default = "t2.large" } variable "availability_zones" { - type = list(string) description = "Used availability zones" + type = list(string) } variable "vpc_id" { - type = string description = "Id of the vpc used for this deployment" + type = string } variable "subnet_address_range" { - type = list(string) description = "List with subnet address ranges in cidr notation to create the netweaver subnets" + type = list(string) } variable "key_name" { - type = string description = "AWS key pair name" + type = string } variable "security_group_id" { - type = string description = "Security group id" + type = string } variable "route_table_id" { - type = string description = "Route table id" + type = string } variable "aws_credentials" { diff --git a/terraform/aws/modules/hana_node/main.tf b/terraform/aws/modules/hana_node/main.tf index 663b4049..3e4ff053 100644 --- a/terraform/aws/modules/hana_node/main.tf +++ b/terraform/aws/modules/hana_node/main.tf @@ -50,7 +50,7 @@ module "get_os_image" { resource "aws_instance" "hana" { count = var.hana_count ami = module.get_os_image.image_id - instance_type = var.instance_type + instance_type = var.vm_size key_name = var.key_name associate_public_ip_address = true #disable_api_stop = false # see https://docs.aws.amazon.com/sap/latest/sap-hana/sap-hana-on-aws-cluster-configuration.html diff --git a/terraform/aws/modules/hana_node/variables.tf b/terraform/aws/modules/hana_node/variables.tf index ca736898..2f5e78f7 100644 --- a/terraform/aws/modules/hana_node/variables.tf +++ b/terraform/aws/modules/hana_node/variables.tf @@ -18,8 +18,9 @@ variable "hana_count" { default = 2 } -variable "instance_type" { - type = string +variable "vm_size" { + description = "The instance type of hana node" + type = string } variable "availability_zones" { diff --git a/terraform/aws/modules/iscsi_server/main.tf b/terraform/aws/modules/iscsi_server/main.tf index 3a75938f..0b216b3f 100644 --- a/terraform/aws/modules/iscsi_server/main.tf +++ b/terraform/aws/modules/iscsi_server/main.tf @@ -13,7 +13,7 @@ module "get_os_image" { resource "aws_instance" "iscsisrv" { count = var.iscsi_count ami = module.get_os_image.image_id - instance_type = var.instance_type + instance_type = var.vm_size key_name = var.key_name associate_public_ip_address = true subnet_id = element(var.subnet_ids, count.index) diff --git a/terraform/aws/modules/iscsi_server/variables.tf b/terraform/aws/modules/iscsi_server/variables.tf index 2c335523..2ccaee60 100644 --- a/terraform/aws/modules/iscsi_server/variables.tf +++ b/terraform/aws/modules/iscsi_server/variables.tf @@ -27,7 +27,7 @@ variable "iscsi_count" { type = number } -variable "instance_type" { +variable "vm_size" { description = "The instance type of iscsi server node." type = string } diff --git a/terraform/aws/modules/monitoring/main.tf b/terraform/aws/modules/monitoring/main.tf index 62a9c4cb..20aac22a 100644 --- a/terraform/aws/modules/monitoring/main.tf +++ b/terraform/aws/modules/monitoring/main.tf @@ -11,7 +11,7 @@ module "get_os_image" { resource "aws_instance" "monitoring" { count = var.monitoring_enabled == true ? 1 : 0 ami = module.get_os_image.image_id - instance_type = var.instance_type + instance_type = var.vm_size key_name = var.key_name associate_public_ip_address = true subnet_id = element(var.subnet_ids, 0) diff --git a/terraform/aws/modules/monitoring/variables.tf b/terraform/aws/modules/monitoring/variables.tf index 4ac3e7e2..242798f5 100644 --- a/terraform/aws/modules/monitoring/variables.tf +++ b/terraform/aws/modules/monitoring/variables.tf @@ -2,21 +2,22 @@ variable "common_variables" { description = "Output of the common_variables module" } +variable "name" { + description = "hostname, without the domain part" + type = string +} + variable "monitoring_enabled" { description = "enable the host to be monitored by exporters, e.g node_exporter" type = bool default = false } -variable "instance_type" { +variable "vm_size" { description = "The instance type of monitoring node." type = string } -variable "name" { - description = "hostname, without the domain part" - type = string -} variable "network_domain" { description = "hostname's network domain" diff --git a/terraform/aws/modules/netweaver_node/main.tf b/terraform/aws/modules/netweaver_node/main.tf index 504e156d..e228243b 100644 --- a/terraform/aws/modules/netweaver_node/main.tf +++ b/terraform/aws/modules/netweaver_node/main.tf @@ -83,7 +83,7 @@ module "get_os_image" { resource "aws_instance" "netweaver" { count = local.vm_count ami = module.get_os_image.image_id - instance_type = var.instance_type + instance_type = var.vm_size key_name = var.key_name associate_public_ip_address = true subnet_id = element(aws_subnet.netweaver-subnet.*.id, count.index % 2) # %2 is used because there are not more than 2 subnets diff --git a/terraform/aws/modules/netweaver_node/variables.tf b/terraform/aws/modules/netweaver_node/variables.tf index ed461e31..16747ee1 100644 --- a/terraform/aws/modules/netweaver_node/variables.tf +++ b/terraform/aws/modules/netweaver_node/variables.tf @@ -2,21 +2,11 @@ variable "common_variables" { description = "Output of the common_variables module" } -variable "xscs_server_count" { - type = number - default = 2 -} - variable "app_server_count" { type = number default = 2 } -variable "instance_type" { - description = "The instance type of netweaver node." - type = string -} - variable "name" { description = "hostname, without the domain part" type = string @@ -27,6 +17,17 @@ variable "network_domain" { type = string } +variable "xscs_server_count" { + description = "Number of xscs nodes" + type = number + default = 2 +} + +variable "vm_size" { + description = "The instance type of netweaver node." + type = string +} + variable "availability_zones" { description = "Used availability zones" type = list(string) diff --git a/terraform/azure/modules/drbd_node/variables.tf b/terraform/azure/modules/drbd_node/variables.tf index 59893e5e..e0169dec 100644 --- a/terraform/azure/modules/drbd_node/variables.tf +++ b/terraform/azure/modules/drbd_node/variables.tf @@ -11,18 +11,27 @@ variable "resource_group_name" { type = string } +variable "drbd_count" { + description = "Number of drbd machines to create the cluster" + type = number + default = 2 +} + +variable "vm_size" { + description = "The instance type of drbd node" + type = string + default = "Standard_D2s_v3" +} + variable "network_subnet_id" { type = string } variable "storage_account" { - type = string + description = "Storage account name needed for the boot diagnostic" + type = string } -variable "drbd_count" { - type = string - default = "2" -} variable "host_ips" { description = "ip addresses to set to the nodes" @@ -45,10 +54,6 @@ variable "name" { type = string } -variable "vm_size" { - type = string - default = "Standard_D2s_v3" -} variable "network_domain" { description = "hostname's network domain" diff --git a/terraform/azure/modules/hana_node/variables.tf b/terraform/azure/modules/hana_node/variables.tf index a3a9056e..7b6536c5 100644 --- a/terraform/azure/modules/hana_node/variables.tf +++ b/terraform/azure/modules/hana_node/variables.tf @@ -20,7 +20,8 @@ variable "network_subnet_netapp_id" { } variable "storage_account" { - type = string + description = "Storage account name needed for the boot diagnostic" + type = string } variable "hana_count" {