diff --git a/main.tf b/main.tf index 7b9222a..fc9074e 100644 --- a/main.tf +++ b/main.tf @@ -153,10 +153,15 @@ resource "aws_spot_instance_request" "windows_instance" { install_auto_login=var.install_auto_login, install_graphic_card_driver=var.install_graphic_card_driver, install_steam=var.install_steam, + install_steam_cmd=var.install_steam_cmd, install_gog_galaxy=var.install_gog_galaxy, install_origin=var.install_origin, install_epic_games_launcher=var.install_epic_games_launcher, install_uplay=var.install_uplay, + steam_account_email=var.steam_account_email, + steam_account_password=var.steam_account_password, + steam_app_id=var.steam_app_id, + server_address=var.server_address, } }) iam_instance_profile = aws_iam_instance_profile.windows_instance_profile.id diff --git a/templates/user_data.tpl b/templates/user_data.tpl index 4d1a57e..d5832e8 100644 --- a/templates/user_data.tpl +++ b/templates/user_data.tpl @@ -12,6 +12,18 @@ function install-chocolatey { choco feature enable -n allowGlobalConfirmation } +function generate-game-start-script { + Set-Content -Path C:\start_game.txt -Value '@ShutdownOnFailedCommand 1','@NoPromptForPassword 1','force_install_dir C:\gamedir','login ${var.steam_account_email} ${var.steam_account_password}','app_update ${var.steam_app_id} validate','quit' +} + +function install-game { + steamcmd +runscript C:\start_game.txt +} + +function start-game { + Start-Process "${var.server_address}" +} + function install-parsec-cloud-preparation-tool { # https://github.com/jamesstringerparsec/Parsec-Cloud-Preparation-Tool $desktopPath = [Environment]::GetFolderPath("Desktop") @@ -148,6 +160,10 @@ install-graphic-driver choco install steam %{ endif } +%{ if var.install_steam_cmd } +choco install steamcmd +%{ endif } + %{ if var.install_gog_galaxy } choco install goggalaxy %{ endif } @@ -164,4 +180,7 @@ choco install origin choco install epicgameslauncher %{ endif } +generate-game-start-script +install-game +start-game diff --git a/terraform.tfvars.exemple b/terraform.tfvars.exemple index 95f60a2..8d11a67 100644 --- a/terraform.tfvars.exemple +++ b/terraform.tfvars.exemple @@ -3,6 +3,10 @@ region = "" #instance_type = "g4dn.xlarge" #root_block_device_size_gb = 120 custom_ami = "" +steam_account_email = "someemail@domain.com" +steam_account_password = "somepassword" +steam_app_id = "686810" +server_address = "steam://connect/192.169.89.50:26662" #install_parsec=true #install_auto_login=true diff --git a/variables.tf b/variables.tf index 15c4a1a..05eaca9 100644 --- a/variables.tf +++ b/variables.tf @@ -64,6 +64,36 @@ variable "install_steam" { default = true } +variable "install_steam_cmd" { + description = "Download and install Valve Steam CMD on first boot" + type = bool + default = true +} +variable "steam_account_email" { + description = "steam_account_email" + type = string + default = "na" +} + +variable "steam_account_password" { + description = "steam_account_password" + type = string + default = "na" +} + +variable "steam_app_id" { + description = "steam_app_id" + type = string + default = "na" +} + +variable "server_address" { + description = "server_address" + type = string + default = "na" +} + + variable "install_gog_galaxy" { description = "Download and install GOG Galaxy on first boot" type = bool