Compare commits

..

1 Commits

Author SHA1 Message Date
003ecb509a bump azurerm to v3 2024-10-04 09:57:18 +08:00
8 changed files with 380 additions and 401 deletions

View File

@ -8,7 +8,7 @@ terraform {
}
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
version = "~>2.0"
}
random = {
source = "hashicorp/random"

View File

@ -4,14 +4,8 @@ locals {
hub-nva-resource-group = "hub-nva-rg"
}
resource "random_string" "suffix" {
length = 5
special = false
upper = false
}
resource "azurerm_resource_group" "hub-nva-rg" {
name = "${local.prefix-hub-nva}-rg-${random_string.suffix.result}"
name = "${local.prefix-hub-nva}-rg"
location = local.hub-nva-location
tags = {
@ -61,7 +55,7 @@ resource "azurerm_virtual_machine" "hub-nva-vm" {
os_profile {
computer_name = "${local.prefix-hub-nva}-vm"
admin_username = var.username
admin_password = local.password
admin_password = var.password
}
os_profile_linux_config {
@ -84,7 +78,7 @@ resource "azurerm_virtual_machine_extension" "enable-routes" {
settings = <<SETTINGS
{
"fileUris": [
"https://raw.githubusercontent.com/lonegunmanb/reference-architectures/refs/heads/master/scripts/linux/enable-ip-forwarding.sh"
"https://raw.githubusercontent.com/mspnp/reference-architectures/master/scripts/linux/enable-ip-forwarding.sh"
],
"commandToExecute": "bash enable-ip-forwarding.sh"
}
@ -148,7 +142,7 @@ resource "azurerm_route_table" "spoke1-rt" {
route {
name = "default"
address_prefix = "0.0.0.0/0"
next_hop_type = "VnetLocal"
next_hop_type = "vnetlocal"
}
tags = {
@ -184,7 +178,7 @@ resource "azurerm_route_table" "spoke2-rt" {
route {
name = "default"
address_prefix = "0.0.0.0/0"
next_hop_type = "VnetLocal"
next_hop_type = "vnetlocal"
}
tags = {

View File

@ -1,7 +1,7 @@
locals {
prefix-hub = "hub"
hub-location = "eastus"
hub-resource-group = "hub-vnet-rg-${random_string.suffix.result}"
hub-resource-group = "hub-vnet-rg"
shared-key = "4-v3ry-53cr37-1p53c-5h4r3d-k3y"
}
@ -84,7 +84,7 @@ resource "azurerm_virtual_machine" "hub-vm" {
os_profile {
computer_name = "${local.prefix-hub}-vm"
admin_username = var.username
admin_password = local.password
admin_password = var.password
}
os_profile_linux_config {

View File

@ -5,24 +5,11 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
version = "~>2.0"
}
}
}
provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}
resource "random_password" "password" {
count = var.password == null ? 1 : 0
length = 20
}
locals {
password = try(random_password.password[0].result, var.password)
features {}
}

View File

@ -1,6 +1,6 @@
locals {
onprem-location = "eastus"
onprem-resource-group = "onprem-vnet-rg-${random_string.suffix.result}"
onprem-resource-group = "onprem-vnet-rg"
prefix-onprem = "onprem"
}
@ -111,7 +111,7 @@ resource "azurerm_virtual_machine" "onprem-vm" {
os_profile {
computer_name = "${local.prefix-onprem}-vm"
admin_username = var.username
admin_password = local.password
admin_password = var.password
}
os_profile_linux_config {

View File

@ -1,6 +1,6 @@
locals {
spoke1-location = "eastus"
spoke1-resource-group = "spoke1-vnet-rg-${random_string.suffix.result}"
spoke1-resource-group = "spoke1-vnet-rg"
prefix-spoke1 = "spoke1"
}
@ -84,7 +84,7 @@ resource "azurerm_virtual_machine" "spoke1-vm" {
os_profile {
computer_name = "${local.prefix-spoke1}-vm"
admin_username = var.username
admin_password = local.password
admin_password = var.password
}
os_profile_linux_config {

View File

@ -1,6 +1,6 @@
locals {
spoke2-location = "eastus"
spoke2-resource-group = "spoke2-vnet-rg-${random_string.suffix.result}"
spoke2-resource-group = "spoke2-vnet-rg"
prefix-spoke2 = "spoke2"
}
@ -88,7 +88,7 @@ resource "azurerm_virtual_machine" "spoke2-vm" {
os_profile {
computer_name = "${local.prefix-spoke2}-vm"
admin_username = var.username
admin_password = local.password
admin_password = var.password
}
os_profile_linux_config {

View File

@ -10,8 +10,6 @@ variable "username" {
variable "password" {
description = "Password for Virtual Machines"
sensitive = true
default = null
}
variable "vmsize" {