Skip to content

Commit cb2be26

Browse files
authored
Various updates (geekzter#50)
* Disable Bedrock container by default * Update providers * Install missing .NET 6 SDK * Fix resource replacement validation
1 parent a98304b commit cb2be26

File tree

6 files changed

+88
-72
lines changed

6 files changed

+88
-72
lines changed

Brewfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ tap "isen-ng/dotnet-sdk-versions"
33

44
brew "azure-cli"
55
brew "azure-functions-core-tools@3"
6-
#brew "hashicorp/tap/terraform"
6+
brew "hashicorp/tap/terraform"
77
brew "jq"
88
brew "tfenv"
99

10-
# cask "dotnet-sdk" # Latest
11-
cask "dotnet-sdk3-1-400" # LTS
10+
cask "dotnet-sdk6"
1211
cask "powershell"

scripts/functions.ps1

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,7 @@ function Invoke (
213213
) {
214214
Write-Host "`n$cmd" -ForegroundColor Green
215215
Invoke-Expression $cmd
216-
$exitCode = $LASTEXITCODE
217-
if ($exitCode -ne 0) {
218-
Write-Warning "'$cmd' exited with status $exitCode"
219-
exit $exitCode
220-
}
216+
Validate-ExitCode $cmd
221217
}
222218

223219
function Migrate-StorageShareState (
@@ -471,6 +467,16 @@ function TearDown-Resources (
471467
}
472468
}
473469

470+
function Validate-ExitCode (
471+
[string]$cmd
472+
) {
473+
$exitCode = $LASTEXITCODE
474+
if ($exitCode -ne 0) {
475+
Write-Warning "'$cmd' exited with status $exitCode"
476+
exit $exitCode
477+
}
478+
}
479+
474480
function Validate-Plan (
475481
[parameter(Mandatory=$true)][string]$File
476482
) {
@@ -484,9 +490,18 @@ function Validate-Plan (
484490
# Validation
485491
# Check whether key resources will be replaced
486492
if (Get-Command jq -ErrorAction SilentlyContinue) {
487-
$containerGroupIDsToReplace = $planJSON | jq '.resource_changes[] | select(.address|endswith(\"azurerm_container_group.minecraft_server\")) | select(.change.actions[]|contains(\"delete\")) | .change.before.id' | ConvertFrom-Json
488-
$serverFQDNIDsToReplace = $planJSON | jq '.resource_changes[] | select(.address|endswith(\"azurerm_dns_cname_record.vanity_hostname[0]\")) | select(.change.actions[]|contains(\"delete\")) | .change.before.id' | ConvertFrom-Json
489-
$minecraftDataIDsToReplace = $planJSON | jq '.resource_changes[] | select(.address|endswith(\"azurerm_storage_share.minecraft_share\")) | select(.change.actions[]|contains(\"delete\")) | .change.before.id' | ConvertFrom-Json
493+
$psNativeCommandArgumentPassingBackup = $PSNativeCommandArgumentPassing
494+
try {
495+
$PSNativeCommandArgumentPassing = "Legacy"
496+
$containerGroupIDsToReplace = $planJSON | jq -r '.resource_changes[] | select(.address|endswith(\"azurerm_container_group.minecraft_server\")) | select( any (.change.actions[];contains(\"delete\"))) | .change.before.id'
497+
Validate-ExitCode "jq"
498+
$serverFQDNIDsToReplace = $planJSON | jq -r '.resource_changes[] | select(.address|endswith(\"azurerm_dns_cname_record.vanity_hostname[0]\")) | select( any (.change.actions[];contains(\"delete\"))) | .change.before.id'
499+
Validate-ExitCode "jq"
500+
$minecraftDataIDsToReplace = $planJSON | jq -r '.resource_changes[] | select(.address|endswith(\"azurerm_storage_share.minecraft_share\")) | select( any (.change.actions[];contains(\"delete\"))) | .change.before.id'
501+
Validate-ExitCode "jq"
502+
} finally {
503+
$PSNativeCommandArgumentPassing = $psNativeCommandArgumentPassingBackup
504+
}
490505
} else {
491506
Write-Warning "jq not found, plan validation skipped. Look at the plan carefully before approving"
492507
if ($Force) {

terraform/.terraform-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.4
1+
latest

terraform/.terraform.lock.hcl

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/config.auto.example.tfvars

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
# enable_backup = true
55
# enable_log_filter = false
66

7+
# variable minecraft_bedrock_config {
8+
# primary = {
9+
# allow_ops_only = false
10+
# container_image = "itzg/minecraft-bedrock-server"
11+
# container_image_tag = "latest"
12+
# environment_variables = {
13+
# ALLOW_CHEATS = false
14+
# DEBUG = "true" # Bedrock is Alpha software
15+
# DIFFICULTY = "easy"
16+
# EULA = true
17+
# GAMEMODE = "creative"
18+
# MAX_PLAYERS = 10
19+
# OVERRIDE_SERVER_PROPERTIES = true
20+
# VERSION = "LATEST"
21+
# }
22+
# minecraft_server_port = 19132
23+
# start_time = ""
24+
# stop_time = "00:01"
25+
# vanity_hostname_prefix = "bedrock"
26+
# }
27+
# }
28+
729
# minecraft_config = {
830
# primary = {
931
# allow_ops_only = "false"

terraform/variables.tf

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,7 @@ variable log_filter_jar {
4848

4949
variable minecraft_bedrock_config {
5050
type = map
51-
default = {
52-
primary = {
53-
allow_ops_only = false
54-
container_image = "itzg/minecraft-bedrock-server"
55-
container_image_tag = "latest"
56-
environment_variables = {
57-
ALLOW_CHEATS = false
58-
DEBUG = "true" # Bedrock is Alpha software
59-
DIFFICULTY = "easy"
60-
EULA = true
61-
GAMEMODE = "creative"
62-
MAX_PLAYERS = 10
63-
OVERRIDE_SERVER_PROPERTIES = true
64-
VERSION = "LATEST"
65-
}
66-
minecraft_server_port = 19132
67-
start_time = ""
68-
stop_time = "00:01"
69-
vanity_hostname_prefix = "bedrock"
70-
}
71-
}
51+
default = {}
7252
}
7353
variable minecraft_bedrock_ops {
7454
type = list

0 commit comments

Comments
 (0)