| 1 |
provider "azurerm" { |
| 2 |
version = "~> 1.20.0" |
| 3 |
} |
| 4 |
|
| 5 |
provider "random" { |
| 6 |
version = "~> 2.0.0" |
| 7 |
} |
| 8 |
|
| 9 |
variable "prefix" { |
| 10 |
default = "go-discover-azurerm" |
| 11 |
} |
| 12 |
|
| 13 |
resource "azurerm_resource_group" "test" { |
| 14 |
name = "${var.prefix}-dev" |
| 15 |
location = "West Europe" |
| 16 |
} |
| 17 |
|
| 18 |
module "network" { |
| 19 |
source = "./modules/network" |
| 20 |
name = "${var.prefix}-internalnw" |
| 21 |
resource_group_name = "${azurerm_resource_group.test.name}" |
| 22 |
location = "${azurerm_resource_group.test.location}" |
| 23 |
address_space = "10.0.0.0/16" |
| 24 |
subnet_cidr = "10.0.1.0/24" |
| 25 |
} |
| 26 |
|
| 27 |
module "vm01" { |
| 28 |
source = "./modules/virtual_machine" |
| 29 |
name = "${var.prefix}-01" |
| 30 |
resource_group_name = "${azurerm_resource_group.test.name}" |
| 31 |
location = "${azurerm_resource_group.test.location}" |
| 32 |
subnet_id = "${module.network.subnet_id}" |
| 33 |
|
| 34 |
tags { |
| 35 |
"consul" = "server" |
| 36 |
} |
| 37 |
} |
| 38 |
|
| 39 |
module "vm02" { |
| 40 |
source = "./modules/virtual_machine" |
| 41 |
name = "${var.prefix}-02" |
| 42 |
resource_group_name = "${azurerm_resource_group.test.name}" |
| 43 |
location = "${azurerm_resource_group.test.location}" |
| 44 |
subnet_id = "${module.network.subnet_id}" |
| 45 |
|
| 46 |
tags { |
| 47 |
"consul" = "server" |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
// We intentionally don't tag the last machine to ensure we only discover the |
| 52 |
// first two |
| 53 |
module "vm03" { |
| 54 |
source = "./modules/virtual_machine" |
| 55 |
name = "${var.prefix}-03" |
| 56 |
resource_group_name = "${azurerm_resource_group.test.name}" |
| 57 |
location = "${azurerm_resource_group.test.location}" |
| 58 |
subnet_id = "${module.network.subnet_id}" |
| 59 |
} |