From 680c56992df1e696a14535e6f324fc94523f0cdc Mon Sep 17 00:00:00 2001 From: Eric van Wijk Date: Sat, 30 Nov 2024 20:42:22 +0100 Subject: [PATCH] azurerm 4.12 (#67) * azurerm 4.12 --- terraform/.terraform.lock.hcl | 28 +++++++++---------- terraform/modules.tf | 2 +- terraform/modules/minecraft-instance/main.tf | 5 ++-- .../modules/minecraft-instance/storage.tf | 21 ++++++-------- .../modules/minecraft-instance/variables.tf | 2 +- terraform/provider.tf | 2 +- terraform/storage.tf | 2 +- 7 files changed, 30 insertions(+), 32 deletions(-) diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl index bbacee1..65ed943 100644 --- a/terraform/.terraform.lock.hcl +++ b/terraform/.terraform.lock.hcl @@ -22,22 +22,22 @@ provider "registry.terraform.io/hashicorp/azuread" { } provider "registry.terraform.io/hashicorp/azurerm" { - version = "3.117.0" - constraints = "~> 3.58" + version = "4.12.0" + constraints = "~> 4.0" hashes = [ - "h1:pAXy9cKU+bX1rvWog4YWeLbg7VFHqRTAFKbjayIXK1k=", - "zh:2e25f47492366821a786762369f0e0921cc9452d64bfd5075f6fdfcf1a9c6d70", - "zh:41eb34f2f7469bf3eb1019dfb0e7fc28256f809824016f4f8b9d691bf473b2ac", - "zh:48bb9c87b3d928da1abc1d3db75453c9725de4674c612daf3800160cc7145d30", - "zh:5d6b0de0bbd78943fcc65c53944ef4496329e247f434c6eab86ed051c5cea67b", - "zh:78c9f6fdb1206a89cf0e6706b4f46178169a93b6c964a4cad8a321058ccbd9b4", - "zh:793b702c352589d4360b580d4a1cf654a7439d2ad6bdb7bfea91de07bc4b0fac", - "zh:7ed687ff0a5509463a592f97431863574fe5cc80a34e395be06766215b8c6285", - "zh:955ba18789bd15592824eb426a8d0f38595bd09fffc6939c1c58933489c1a71e", - "zh:bf5949a55be0714cd9c8815d472eae4baa48ba06d0f6bf2b96775869acda8a54", - "zh:da5d31f635abd2c645ffc76d6176d73f646128e73720cc368247cc424975c127", - "zh:eed5a66d59883c9c56729b0a964a2b60d758ea7489ef3e920a6fbd48518ce5f5", + "h1:tI7FQgfIFIER3wMbZN5mIX24B0mWVNb4r7hi7mUmAw8=", + "zh:127709945923a0034ec302c41494b82f0748707ecba15feba9db3af03e2b4709", + "zh:16ce5040984456f332598e1515cfde12b1bba78eae37b7a4b08ec332bbb55d6c", + "zh:1901cf598a048a1f135ed1c723de5e3c501aa7d1399490b7722c44cb61cb566e", + "zh:1b4a1fa65f32de535481ff38bd5869f44582b14b64bd00cc4902439cf2728a8a", + "zh:72ff727353151bd1a41ea1d6b2ecf24157918658ccd02d56acd62a7c4d330a7b", + "zh:78c0e4d7e1701fc5b3227d098807b1ed1c6d80c1ee443c0db89c64aeb317a39f", + "zh:a9964f7d9142cdd6f84673e1e936491f14bf1a44dd51fd55525c42fb05208c83", + "zh:ada1ffdebe10a44fcfa330618376fbd5d5daf7a9faad833496162686a98016d0", + "zh:d02d4d5a1fc4b0cb7975311bf37596456ace782ab195281a48338eb2a0f478c1", + "zh:e0fb626158b0cb7d8c5662a518cee8924b00a87312feff9db40b30e26539aa0f", "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + "zh:fa5f683582bc5b12587aa7a78152774f2eaae9cfac0fb61b6de81284abbbea5b", ] } diff --git a/terraform/modules.tf b/terraform/modules.tf index 598d6ab..f16f6a9 100644 --- a/terraform/modules.tf +++ b/terraform/modules.tf @@ -49,7 +49,7 @@ module minecraft { resource_group_id = azurerm_resource_group.minecraft.id resource_group_name = azurerm_resource_group.minecraft.name - storage_account_name = azurerm_storage_account.minecraft.name + storage_account_id = azurerm_storage_account.minecraft.id storage_account_key = azurerm_storage_account.minecraft.primary_access_key tags = merge( azurerm_resource_group.minecraft.tags, diff --git a/terraform/modules/minecraft-instance/main.tf b/terraform/modules/minecraft-instance/main.tf index ab52961..1719e0b 100644 --- a/terraform/modules/minecraft-instance/main.tf +++ b/terraform/modules/minecraft-instance/main.tf @@ -23,6 +23,7 @@ locals { # https://github.com/itzg/docker-minecraft-server container_image = var.container_image_tag != null && var.container_image_tag != "" ? "${var.container_image}:${var.container_image_tag}" : var.container_image minecraft_server_fqdn = var.vanity_dns_zone_id != "" ? replace(try(azurerm_dns_cname_record.vanity_hostname.0.fqdn,""),"/\\W*$/","") : azurerm_container_group.minecraft_server.fqdn + storage_account_name = split("/",var.storage_account_id)[8] tags = merge( var.tags, @@ -71,7 +72,7 @@ resource azurerm_container_group minecraft_server { name = "azurefile" read_only = false share_name = azurerm_storage_share.minecraft_share.name - storage_account_name = var.storage_account_name + storage_account_name = local.storage_account_name storage_account_key = var.storage_account_key } volume { @@ -79,7 +80,7 @@ resource azurerm_container_group minecraft_server { name = "modpacks" read_only = false share_name = azurerm_storage_share.minecraft_modpacks.name - storage_account_name = var.storage_account_name + storage_account_name = local.storage_account_name storage_account_key = var.storage_account_key } } diff --git a/terraform/modules/minecraft-instance/storage.tf b/terraform/modules/minecraft-instance/storage.tf index e2acdab..acaf371 100644 --- a/terraform/modules/minecraft-instance/storage.tf +++ b/terraform/modules/minecraft-instance/storage.tf @@ -3,13 +3,13 @@ locals { } data azurerm_storage_account minecraft { - name = var.storage_account_name + name = local.storage_account_name resource_group_name = var.resource_group_name } resource azurerm_storage_blob minecraft_configuration { name = "${local.config_directory}/config.json" - storage_account_name = var.storage_account_name + storage_account_name = local.storage_account_name storage_container_name = var.configuration_storage_container_name type = "Block" source_content = jsonencode(local.config) @@ -17,7 +17,7 @@ resource azurerm_storage_blob minecraft_configuration { resource azurerm_storage_blob minecraft_environment { name = "${local.config_directory}/environment.json" - storage_account_name = var.storage_account_name + storage_account_name = local.storage_account_name storage_container_name = var.configuration_storage_container_name type = "Block" source_content = jsonencode(local.environment_variables) @@ -25,7 +25,7 @@ resource azurerm_storage_blob minecraft_environment { resource azurerm_storage_blob minecraft_user_configuration { name = "${local.config_directory}/users.json" - storage_account_name = var.storage_account_name + storage_account_name = local.storage_account_name storage_container_name = var.configuration_storage_container_name type = "Block" source_content = jsonencode(var.minecraft_users) @@ -33,28 +33,26 @@ resource azurerm_storage_blob minecraft_user_configuration { resource azurerm_storage_share minecraft_share { name = var.container_data_share_name - storage_account_name = var.storage_account_name + storage_account_name = local.storage_account_name quota = 50 } resource azurerm_storage_share minecraft_modpacks { name = var.container_modpacks_share_name - storage_account_name = var.storage_account_name + storage_account_id = var.storage_account_id quota = 50 } # https://www.spigotmc.org/resources/console-spam-fix.18410/download?version=366123 resource azurerm_storage_share_directory plugins { name = "plugins" - share_name = azurerm_storage_share.minecraft_share.name - storage_account_name = var.storage_account_name + storage_share_id = azurerm_storage_share.minecraft_share.id count = var.enable_log_filter ? 1 : 0 } resource azurerm_storage_share_directory bstats { name = "${azurerm_storage_share_directory.plugins.0.name}/bStats" - share_name = azurerm_storage_share.minecraft_share.name - storage_account_name = var.storage_account_name + storage_share_id = azurerm_storage_share.minecraft_share.id count = var.enable_log_filter ? 1 : 0 } @@ -69,8 +67,7 @@ resource azurerm_storage_share_file bstats_config { } resource azurerm_storage_share_directory log_filter { name = "${azurerm_storage_share_directory.plugins.0.name}/ConsoleSpamFix" - share_name = azurerm_storage_share.minecraft_share.name - storage_account_name = var.storage_account_name + storage_share_id = azurerm_storage_share.minecraft_share.id count = var.enable_log_filter ? 1 : 0 } diff --git a/terraform/modules/minecraft-instance/variables.tf b/terraform/modules/minecraft-instance/variables.tf index 103c4b4..56123cd 100644 --- a/terraform/modules/minecraft-instance/variables.tf +++ b/terraform/modules/minecraft-instance/variables.tf @@ -111,8 +111,8 @@ variable timezone { } variable configuration_storage_container_name {} +variable storage_account_id {} variable storage_account_key {} -variable storage_account_name {} variable tags { type = map diff --git a/terraform/provider.tf b/terraform/provider.tf index 7951627..fe89b48 100644 --- a/terraform/provider.tf +++ b/terraform/provider.tf @@ -1,7 +1,7 @@ terraform { required_providers { azuread = "~> 2.12" - azurerm = "~> 3.58" + azurerm = "~> 4.12" http = "~> 3.0" null = "~> 3.1" random = "~> 3.1" diff --git a/terraform/storage.tf b/terraform/storage.tf index 944fe59..4337077 100644 --- a/terraform/storage.tf +++ b/terraform/storage.tf @@ -21,7 +21,7 @@ resource azurerm_storage_account minecraft { resource azurerm_storage_container configuration { name = "configuration" - storage_account_name = azurerm_storage_account.minecraft.name + storage_account_id = azurerm_storage_account.minecraft.id container_access_type = "private" }