diff --git a/main.tf b/main.tf index 645bb6d2f1..d77e35d71c 100644 --- a/main.tf +++ b/main.tf @@ -200,6 +200,7 @@ module "runners" { instance_allocation_strategy = var.instance_allocation_strategy instance_max_spot_price = var.instance_max_spot_price block_device_mappings = var.block_device_mappings + gh_url = var.gh_url runner_architecture = var.runner_architecture ami_filter = var.ami_filter diff --git a/modules/runners/runner-config.tf b/modules/runners/runner-config.tf index 684873a7ff..4704de2bf4 100644 --- a/modules/runners/runner-config.tf +++ b/modules/runners/runner-config.tf @@ -12,6 +12,13 @@ resource "aws_ssm_parameter" "runner_agent_mode" { tags = local.tags } +resource "aws_ssm_parameter" "gh_url" { + name = "${var.ssm_paths.root}/${var.ssm_paths.config}/gh_url" + type = "String" + value = var.gh_url + tags = local.tags +} + resource "aws_ssm_parameter" "jit_config_enabled" { name = "${var.ssm_paths.root}/${var.ssm_paths.config}/enable_jit_config" type = "String" diff --git a/modules/runners/templates/start-runner.ps1 b/modules/runners/templates/start-runner.ps1 index 5046d3e9dd..b0558e07cd 100644 --- a/modules/runners/templates/start-runner.ps1 +++ b/modules/runners/templates/start-runner.ps1 @@ -54,6 +54,9 @@ Write-Host "Retrieved $ssm_config_path/agent_mode parameter - ($agent_mode)" $token_path=$parameters.where( {$_.Name -eq "$ssm_config_path/token_path"}).value Write-Host "Retrieved $ssm_config_path/token_path parameter - ($token_path)" +$gh_url=$parameters.where( {$_.Name -eq "$ssm_config_path/gh_url"}).value +Write-Host "Retrieved $ssm_config_path/gh_url parameter - ($gh_url)" + if ($enable_cloudwatch_agent -eq "true") { @@ -107,7 +110,7 @@ foreach ($group in @("Administrators", "docker-users")) { Set-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -Value 0 -Force Write-Host "Disabled User Access Control (UAC)" -$configCmd = ".\config.cmd --unattended --name $runner_name_prefix$InstanceId --work `"_work`" $config" +$configCmd = ".\config.cmd --unattended --url $gh_url --name $runner_name_prefix$InstanceId --work `"_work`" $config" Write-Host "Configure GH Runner as user $run_as" Invoke-Expression $configCmd diff --git a/modules/runners/variables.tf b/modules/runners/variables.tf index 5c56917259..bc35a7cf7d 100644 --- a/modules/runners/variables.tf +++ b/modules/runners/variables.tf @@ -392,6 +392,12 @@ variable "runner_log_files" { default = null } +variable "gh_url" { + description = "GitHub URL with Org ID included." + type = string + default = null +} + variable "ghes_url" { description = "GitHub Enterprise Server URL. DO NOT SET IF USING PUBLIC GITHUB" type = string diff --git a/variables.tf b/variables.tf index 51bd7d8e10..2361d25c6b 100644 --- a/variables.tf +++ b/variables.tf @@ -40,6 +40,12 @@ variable "github_app" { }) } +variable "gh_url" { + description = "GitHub URL with Org ID included." + type = string + default = null +} + variable "scale_down_schedule_expression" { description = "Scheduler expression to check every x for scale down." type = string