Skip to content

Commit

Permalink
azurerm 4.12 (#67)
Browse files Browse the repository at this point in the history
* azurerm 4.12
  • Loading branch information
geekzter authored Nov 30, 2024
1 parent 6b6622e commit 680c569
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 32 deletions.
28 changes: 14 additions & 14 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion terraform/modules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions terraform/modules/minecraft-instance/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -71,15 +72,15 @@ 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 {
mount_path = "/modpacks"
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
}
}
Expand Down
21 changes: 9 additions & 12 deletions terraform/modules/minecraft-instance/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,56 @@ 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)
}

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)
}

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)
}

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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/minecraft-instance/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion terraform/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down

0 comments on commit 680c569

Please sign in to comment.