From f3f385dd5d41fe257c85ab4ec069d29209964246 Mon Sep 17 00:00:00 2001 From: Denis Iskandarov Date: Mon, 25 Feb 2019 22:24:30 +0400 Subject: [PATCH] fix count variables are only valid within resources Signed-off-by: Denis Iskandarov --- main.tf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 19339d44..74068bc5 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,5 @@ locals { is_t_instance_type = "${replace(var.instance_type, "/^t[23]{1}\\..*$/", "1") == "1" ? "1" : "0"}" - instance_name = "${map("Name", (var.instance_count > 1) || (var.use_num_suffix == "true") ? format("%s-%d", var.name, count.index+1) : var.name)}" } ###### @@ -35,7 +34,7 @@ resource "aws_instance" "this" { placement_group = "${var.placement_group}" tenancy = "${var.tenancy}" - tags = "${merge(local.instance_name, var.tags)}" + tags = "${merge(map("Name", (var.instance_count > 1) || (var.use_num_suffix == "true") ? format("%s-%d", var.name, count.index+1) : var.name), var.tags)}" lifecycle { # Due to several known issues in Terraform AWS provider related to arguments of aws_instance: @@ -78,7 +77,7 @@ resource "aws_instance" "this_t2" { cpu_credits = "${var.cpu_credits}" } - tags = "${merge(local.instance_name, var.tags)}" + tags = "${merge(map("Name", (var.instance_count > 1) || (var.use_num_suffix == "true") ? format("%s-%d", var.name, count.index+1) : var.name), var.tags)}" lifecycle { # Due to several known issues in Terraform AWS provider related to arguments of aws_instance: