From 05fe737375da38d4779af5acdc5c8256718109c4 Mon Sep 17 00:00:00 2001 From: Brian Ojeda <9335829+sgtoj@users.noreply.github.com> Date: Fri, 16 Sep 2022 10:56:32 -0400 Subject: [PATCH] feat: add s3_location_runner_distribution var as expandable for userdata (#2371) --- modules/runners/main.tf | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/runners/main.tf b/modules/runners/main.tf index 76bf3a70ae..9e04adee6c 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -6,13 +6,14 @@ locals { var.tags, ) - name_sg = var.overrides["name_sg"] == "" ? local.tags["Name"] : var.overrides["name_sg"] - name_runner = var.overrides["name_runner"] == "" ? local.tags["Name"] : var.overrides["name_runner"] - role_path = var.role_path == null ? "/${var.prefix}/" : var.role_path - instance_profile_path = var.instance_profile_path == null ? "/${var.prefix}/" : var.instance_profile_path - lambda_zip = var.lambda_zip == null ? "${path.module}/lambdas/runners/runners.zip" : var.lambda_zip - userdata_template = var.userdata_template == null ? local.default_userdata_template[var.runner_os] : var.userdata_template - kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : "" + name_sg = var.overrides["name_sg"] == "" ? local.tags["Name"] : var.overrides["name_sg"] + name_runner = var.overrides["name_runner"] == "" ? local.tags["Name"] : var.overrides["name_runner"] + role_path = var.role_path == null ? "/${var.prefix}/" : var.role_path + instance_profile_path = var.instance_profile_path == null ? "/${var.prefix}/" : var.instance_profile_path + lambda_zip = var.lambda_zip == null ? "${path.module}/lambdas/runners/runners.zip" : var.lambda_zip + userdata_template = var.userdata_template == null ? local.default_userdata_template[var.runner_os] : var.userdata_template + kms_key_arn = var.kms_key_arn != null ? var.kms_key_arn : "" + s3_location_runner_distribution = var.enable_runner_binaries_syncer ? "s3://${var.s3_runner_binaries.id}/${var.s3_runner_binaries.key}" : "" default_ami = { "windows" = { name = ["Windows_Server-2022-English-Core-ContainersLatest-*"] } @@ -132,15 +133,17 @@ resource "aws_launch_template" "runner" { } user_data = var.enabled_userdata ? base64encode(templatefile(local.userdata_template, { - pre_install = var.userdata_pre_install + s3_location_runner_distribution = local.s3_location_runner_distribution + pre_install = var.userdata_pre_install install_runner = templatefile(local.userdata_install_runner[var.runner_os], { - S3_LOCATION_RUNNER_DISTRIBUTION = var.enable_runner_binaries_syncer ? "s3://${var.s3_runner_binaries.id}/${var.s3_runner_binaries.key}" : "" + S3_LOCATION_RUNNER_DISTRIBUTION = local.s3_location_runner_distribution RUNNER_ARCHITECTURE = var.runner_architecture }) post_install = var.userdata_post_install start_runner = templatefile(local.userdata_start_runner[var.runner_os], {}) ghes_url = var.ghes_url ghes_ssl_verify = var.ghes_ssl_verify + ## retain these for backwards compatibility environment = var.prefix enable_cloudwatch_agent = var.enable_cloudwatch_agent