Skip to content

Commit

Permalink
feat: add s3_location_runner_distribution var as expandable for userd…
Browse files Browse the repository at this point in the history
…ata (#2371)
  • Loading branch information
sgtoj authored Sep 16, 2022
1 parent 27db290 commit 05fe737
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions modules/runners/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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-*"] }
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 05fe737

Please sign in to comment.