Changed the method of defining subnets in the main module.
This commit is contained in:
@@ -18,13 +18,7 @@ module "network" {
|
|||||||
source = "./modules/network"
|
source = "./modules/network"
|
||||||
|
|
||||||
name = var.network_name
|
name = var.network_name
|
||||||
subnets = [
|
subnets = var.subnets
|
||||||
{
|
|
||||||
name = var.subnet_name
|
|
||||||
region = var.region
|
|
||||||
cidr = var.subnet_cidr
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module "vm" {
|
module "vm" {
|
||||||
@@ -32,7 +26,7 @@ module "vm" {
|
|||||||
|
|
||||||
name = "vm-test"
|
name = "vm-test"
|
||||||
network_name = var.network_name
|
network_name = var.network_name
|
||||||
subnet_name = var.subnet_name
|
subnet_name = var.subnets[0].name
|
||||||
ssh = var.ssh
|
ssh = var.ssh
|
||||||
|
|
||||||
depends_on = [module.network]
|
depends_on = [module.network]
|
||||||
|
|||||||
+20
-11
@@ -6,13 +6,13 @@ variable "project_id" {
|
|||||||
variable "region" {
|
variable "region" {
|
||||||
description = "The region for the resources."
|
description = "The region for the resources."
|
||||||
type = string
|
type = string
|
||||||
default = "europe-central2"
|
default = "us-west1"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "zone" {
|
variable "zone" {
|
||||||
description = "The zone for the resources."
|
description = "The zone for the resources."
|
||||||
type = string
|
type = string
|
||||||
default = "europe-central2-b"
|
default = "us-west1-a"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "network_name" {
|
variable "network_name" {
|
||||||
@@ -21,16 +21,25 @@ variable "network_name" {
|
|||||||
default = "dom-lab-network"
|
default = "dom-lab-network"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "subnet_name" {
|
variable "subnets" {
|
||||||
description = "The name of the subnet."
|
description = "A list of subnets to create."
|
||||||
type = string
|
|
||||||
default = "waw-default"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "subnet_cidr" {
|
type = list(object({
|
||||||
description = "The CIDR range for the subnet."
|
name = string
|
||||||
type = string
|
cidr = string
|
||||||
default = "192.168.16.0/24"
|
region = string
|
||||||
|
}))
|
||||||
|
|
||||||
|
default = [{
|
||||||
|
name = "waw-default"
|
||||||
|
cidr = "192.168.16.0/24"
|
||||||
|
region = "us-west1"
|
||||||
|
}]
|
||||||
|
|
||||||
|
validation {
|
||||||
|
condition = var.subnets[0].region != null
|
||||||
|
error_message = "The region for the first subnet must be specified."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ssh" {
|
variable "ssh" {
|
||||||
|
|||||||
Reference in New Issue
Block a user