Skip to content

Commit

Permalink
Use vm_size in AWS modules (#265)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mpagot authored Sep 3, 2024
1 parent ec900d6 commit aea9abd
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 46 deletions.
10 changes: 5 additions & 5 deletions terraform/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws/modules/drbd_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions terraform/aws/modules/drbd_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws/modules/hana_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions terraform/aws/modules/hana_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws/modules/iscsi_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws/modules/iscsi_server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws/modules/monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions terraform/aws/modules/monitoring/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform/aws/modules/netweaver_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions terraform/aws/modules/netweaver_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
23 changes: 14 additions & 9 deletions terraform/azure/modules/drbd_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion terraform/azure/modules/hana_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit aea9abd

Please sign in to comment.