Skip to content

Commit

Permalink
feat!: upgrade azurerm provider to v4 (#22)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: * Version 4 of the azurerm provider includes breaking changes.

Co-authored-by: dkool <dkool@dkools-MacBook-Pro.local>
  • Loading branch information
dkooll and dkool authored Sep 25, 2024
1 parent 4ccee4d commit 89944bf
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 157 deletions.
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
.PHONY: test

export TF_PATH
export EXAMPLE

test:
cd tests && go test -v -timeout 60m -run TestApplyNoError/$(TF_PATH) ./rsv_test.go

#test_extended:
#cd tests && env go test -v -timeout 60m -run TestCosmosDbAccount ./rsv_extended_test.go

cd tests && go test -v -timeout 60m -run TestApplyNoError/$(EXAMPLE) ./rsv_test.go
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ End-to-end testing is not conducted on these modules, as they are individual com
| `vault` | describes recovery services vault related configuration |
| `naming` | used for naming purposes | string | yes |
| `location` | default azure region tho be used | string | no |
| `resourcegroup` | default resource group to be used | string | no |
| `resource_group` | default resource group to be used | string | no |
| `tags` | tags to be added to the resources | map(string) | no |

## Outputs
Expand Down
14 changes: 7 additions & 7 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ module "naming" {

module "rg" {
source = "cloudnationhq/rg/azure"
version = "~> 0.1"
version = "~> 2.0"

groups = {
demo = {
name = module.naming.resource_group.name
region = "westeurope"
name = module.naming.resource_group.name
location = "westeurope"
}
}
}

module "rsv" {
source = "cloudnationhq/rsv/azure"
version = "~> 0.1"
version = "~> 1.0"

vault = {
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name
}
}
2 changes: 1 addition & 1 deletion examples/default/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.61"
version = "~> 4.0"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions examples/policies/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ module "naming" {

module "rg" {
source = "cloudnationhq/rg/azure"
version = "~> 0.1"
version = "~> 2.0"

groups = {
demo = {
name = module.naming.resource_group.name
region = "westeurope"
name = module.naming.resource_group.name
location = "westeurope"
}
}
}

module "rsv" {
source = "cloudnationhq/rsv/azure"
version = "~> 0.1"
version = "~> 1.0"

naming = local.naming

vault = {
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name

policies = {
file_shares = {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/policies/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.61"
version = "~> 4.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
locals {
naming = {
# lookup outputs to have consistent naming
for type in local.naming_types : type => lookup(module.naming, type).name
}

naming_types = ["subnet", "network_security_group"]
}

locals {
endpoints = {
vault = {
Expand Down
34 changes: 17 additions & 17 deletions examples/private-endpoint/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ module "naming" {

module "rg" {
source = "cloudnationhq/rg/azure"
version = "~> 0.1"
version = "~> 2.0"

groups = {
demo = {
name = module.naming.resource_group.name
region = "westeurope"
name = module.naming.resource_group.name
location = "westeurope"
}
}
}

module "network" {
source = "cloudnationhq/vnet/azure"
version = "~> 2.0"
version = "~> 4.0"

naming = local.naming

vnet = {
name = module.naming.virtual_network.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
cidr = ["10.19.0.0/16"]
name = module.naming.virtual_network.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name
cidr = ["10.19.0.0/16"]

subnets = {
sn1 = {
Expand All @@ -40,22 +40,22 @@ module "network" {

module "rsv" {
source = "cloudnationhq/rsv/azure"
version = "~> 0.1"
version = "~> 1.0"

vault = {
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name

public_network_access_enabled = false
}
}

module "private_dns" {
source = "cloudnationhq/pdns/azure"
version = "~> 0.1"
version = "~> 2.0"

resourcegroup = module.rg.groups.demo.name
resource_group = module.rg.groups.demo.name

zones = {
vault = {
Expand All @@ -72,10 +72,10 @@ module "private_dns" {

module "privatelink" {
source = "cloudnationhq/pe/azure"
version = "~> 0.1"
version = "~> 1.0"

resourcegroup = module.rg.groups.demo.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name
location = module.rg.groups.demo.location

endpoints = local.endpoints
}
8 changes: 8 additions & 0 deletions examples/private-endpoint/naming.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
naming = {
# lookup outputs to have consistent naming
for type in local.naming_types : type => lookup(module.naming, type).name
}

naming_types = ["subnet", "network_security_group"]
}
2 changes: 1 addition & 1 deletion examples/private-endpoint/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.61"
version = "~> 4.0"
}
}
}
Expand Down
46 changes: 23 additions & 23 deletions examples/protected_vms/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ module "naming" {

module "rg" {
source = "cloudnationhq/rg/azure"
version = "~> 0.1"
version = "~> 2.0"

groups = {
demo = {
name = module.naming.resource_group.name
region = "westeurope"
name = module.naming.resource_group.name
location = "westeurope"
}
}
}

module "network" {
source = "cloudnationhq/vnet/azure"
version = "~> 2.0"
version = "~> 4.0"

naming = local.naming

vnet = {
name = module.naming.virtual_network.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
cidr = ["10.18.0.0/16"]
name = module.naming.virtual_network.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name
cidr = ["10.18.0.0/16"]
subnets = {
int = {
cidr = ["10.18.1.0/24"]
Expand All @@ -43,26 +43,26 @@ module "network" {

module "kv" {
source = "cloudnationhq/kv/azure"
version = "~> 0.1"
version = "~> 2.0"

naming = local.naming

vault = {
name = module.naming.key_vault.name_unique
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
name = module.naming.key_vault.name_unique
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name
}
}

module "vm" {
source = "cloudnationhq/vm/azure"
version = "~> 0.1"
version = "~> 4.0"

naming = local.naming
keyvault = module.kv.vault.id
resourcegroup = module.rg.groups.demo.name
location = module.rg.groups.demo.location
depends_on = [module.kv]
naming = local.naming
keyvault = module.kv.vault.id
resource_group = module.rg.groups.demo.name
location = module.rg.groups.demo.location
depends_on = [module.kv]

for_each = local.vms

Expand All @@ -71,12 +71,12 @@ module "vm" {

module "rsv" {
source = "cloudnationhq/rsv/azure"
version = "~> 0.1"
version = "~> 1.0"

vault = {
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resourcegroup = module.rg.groups.demo.name
policies = local.policies
name = module.naming.recovery_services_vault.name
location = module.rg.groups.demo.location
resource_group = module.rg.groups.demo.name
policies = local.policies
}
}
8 changes: 8 additions & 0 deletions examples/protected_vms/naming.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
locals {
naming = {
# lookup outputs to have consistent naming
for type in local.naming_types : type => lookup(module.naming, type).name
}

naming_types = ["subnet", "network_security_group", "key_vault_secret"]
}
2 changes: 1 addition & 1 deletion examples/protected_vms/terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.61"
version = "~> 4.0"
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions examples/protected_vms/vms.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
locals {
naming = {
# lookup outputs to have consistent naming
for type in local.naming_types : type => lookup(module.naming, type).name
}

naming_types = ["subnet", "network_security_group", "key_vault_secret"]
}

locals {
vms = {
dcroot001 = {
Expand Down
2 changes: 1 addition & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ locals {
protected_vms_map = merge([
for policy_name, policy in lookup(var.vault, "policies", {}) != {} ? lookup(var.vault.policies, "vms", {}) : {} : {
for vm_name, vm_details in lookup(policy, "protected_vms", {}) : "${policy_name}-${vm_name}" => {
resource_group_name = var.vault.resourcegroup
resource_group_name = var.vault.resource_group
recovery_vault_name = var.vault.name,
source_vm_id = vm_details.id,
name = try(policy_name, var.naming.recovery_services_vault_backup_policy)
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# recovery vault
resource "azurerm_recovery_services_vault" "vault" {
name = var.vault.name
resource_group_name = coalesce(lookup(var.vault, "resourcegroup", null), var.resourcegroup)
resource_group_name = coalesce(lookup(var.vault, "resource_group", null), var.resource_group)
location = coalesce(lookup(var.vault, "location", null), var.location)
sku = try(var.vault.sku, "Standard")
soft_delete_enabled = try(var.vault.soft_delete_enabled, false)
Expand All @@ -20,7 +20,7 @@ resource "azurerm_backup_policy_file_share" "policy" {
)

name = try(each.value.name, join("-", [var.naming.recovery_services_vault_backup_policy, each.key]))
resource_group_name = coalesce(try(var.vault.resourcegroup, null), var.resourcegroup)
resource_group_name = coalesce(try(var.vault.resource_group, null), var.resource_group)
recovery_vault_name = azurerm_recovery_services_vault.vault.name
timezone = try(each.value.timezone, "UTC")

Expand Down Expand Up @@ -77,7 +77,7 @@ resource "azurerm_backup_policy_vm" "policy" {
)

name = try(each.value.name, join("-", [var.naming.recovery_services_vault_backup_policy, each.key]))
resource_group_name = coalesce(try(var.vault.resourcegroup, null), var.resourcegroup)
resource_group_name = coalesce(try(var.vault.resource_group, null), var.resource_group)
recovery_vault_name = azurerm_recovery_services_vault.vault.name
timezone = try(each.value.timezone, "UTC")
policy_type = try(each.value.policy_type, "V1")
Expand Down
2 changes: 1 addition & 1 deletion terraform.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.61"
version = "~> 4.0"
}
}
}
Loading

0 comments on commit 89944bf

Please sign in to comment.