From 67c7d13b12c45766fb6eb941995dd1f93868c0b3 Mon Sep 17 00:00:00 2001 From: Laurent Michenaud Date: Tue, 6 Jul 2021 14:42:41 +0200 Subject: [PATCH 1/3] fix: replace deprecated null_data_source with locals --- .gitignore | 1 + main.tf | 2 +- tags.tf | 21 +-------------------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 095e367bd..ad5ab8fed 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Module directory .terraform/ +.terraform.lock.hcl # keys *id_rsa* diff --git a/main.tf b/main.tf index cf6985a1c..b6a7ea91c 100644 --- a/main.tf +++ b/main.tf @@ -164,7 +164,7 @@ resource "aws_autoscaling_group" "gitlab_runner_instance" { health_check_grace_period = 0 launch_configuration = aws_launch_configuration.gitlab_runner_instance.name enabled_metrics = var.metrics_autoscaling - tags = data.null_data_source.agent_tags.*.outputs + tags = local.agent_tags_propagated timeouts { delete = var.asg_delete_timeout } diff --git a/tags.tf b/tags.tf index a49a0c0f6..6cf87ccdf 100644 --- a/tags.tf +++ b/tags.tf @@ -19,6 +19,7 @@ locals { var.tags, var.agent_tags ) + agent_tags_propagated = [ for tag_key, tag_value in local.agent_tags: { key=tag_key, value=tag_value, propagate_at_launch = true }] tags_string = join(",", flatten([ for key in keys(local.tags) : [key, lookup(local.tags, key)] @@ -28,23 +29,3 @@ locals { for key in keys(var.runner_tags) : [key, lookup(var.runner_tags, key)] ])) } - -data "null_data_source" "tags" { - count = length(local.tags) - - inputs = { - key = element(keys(local.tags), count.index) - value = element(values(local.tags), count.index) - propagate_at_launch = "true" - } -} - -data "null_data_source" "agent_tags" { - count = length(local.agent_tags) - - inputs = { - key = element(keys(local.agent_tags), count.index) - value = element(values(local.agent_tags), count.index) - propagate_at_launch = "true" - } -} From c4a550259793cd83197d564c0144aef8f880da77 Mon Sep 17 00:00:00 2001 From: Laurent Michenaud Date: Tue, 6 Jul 2021 14:49:33 +0200 Subject: [PATCH 2/3] fix: indentation --- main.tf | 4 ++-- tags.tf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index b6a7ea91c..deda6214d 100644 --- a/main.tf +++ b/main.tf @@ -38,7 +38,7 @@ resource "null_resource" "remove_runner" { } locals { - enable_asg_recreation = var.enable_forced_updates != null ? ! var.enable_forced_updates : var.enable_asg_recreation + enable_asg_recreation = var.enable_forced_updates != null ? !var.enable_forced_updates : var.enable_asg_recreation template_user_data = templatefile("${path.module}/template/user-data.tpl", { @@ -125,7 +125,7 @@ locals { runners_root_size = var.runners_root_size runners_iam_instance_profile_name = var.runners_iam_instance_profile_name runners_use_private_address_only = var.runners_use_private_address - runners_use_private_address = ! var.runners_use_private_address + runners_use_private_address = !var.runners_use_private_address runners_request_spot_instance = var.runners_request_spot_instance runners_environment_vars = jsonencode(var.runners_environment_vars) runners_pre_build_script = var.runners_pre_build_script diff --git a/tags.tf b/tags.tf index 6cf87ccdf..6e122ca92 100644 --- a/tags.tf +++ b/tags.tf @@ -19,7 +19,7 @@ locals { var.tags, var.agent_tags ) - agent_tags_propagated = [ for tag_key, tag_value in local.agent_tags: { key=tag_key, value=tag_value, propagate_at_launch = true }] + agent_tags_propagated = [for tag_key, tag_value in local.agent_tags : { key = tag_key, value = tag_value, propagate_at_launch = true }] tags_string = join(",", flatten([ for key in keys(local.tags) : [key, lookup(local.tags, key)] From 2eceeb28190df92c3bbb05a5e11fcd1acf992f9d Mon Sep 17 00:00:00 2001 From: Laurent Michenaud Date: Tue, 6 Jul 2021 14:57:26 +0200 Subject: [PATCH 3/3] fix: indentation --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index deda6214d..b6a7ea91c 100644 --- a/main.tf +++ b/main.tf @@ -38,7 +38,7 @@ resource "null_resource" "remove_runner" { } locals { - enable_asg_recreation = var.enable_forced_updates != null ? !var.enable_forced_updates : var.enable_asg_recreation + enable_asg_recreation = var.enable_forced_updates != null ? ! var.enable_forced_updates : var.enable_asg_recreation template_user_data = templatefile("${path.module}/template/user-data.tpl", { @@ -125,7 +125,7 @@ locals { runners_root_size = var.runners_root_size runners_iam_instance_profile_name = var.runners_iam_instance_profile_name runners_use_private_address_only = var.runners_use_private_address - runners_use_private_address = !var.runners_use_private_address + runners_use_private_address = ! var.runners_use_private_address runners_request_spot_instance = var.runners_request_spot_instance runners_environment_vars = jsonencode(var.runners_environment_vars) runners_pre_build_script = var.runners_pre_build_script