Skip to content

Commit 1962a4f

Browse files
den-isantonbabenko
authored andcommitted
fix count variables are only valid within resources (#72)
Signed-off-by: Denis Iskandarov <[email protected]>
1 parent 54358ed commit 1962a4f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
locals {
22
is_t_instance_type = "${replace(var.instance_type, "/^t[23]{1}\\..*$/", "1") == "1" ? "1" : "0"}"
3-
instance_name = "${map("Name", (var.instance_count > 1) || (var.use_num_suffix == "true") ? format("%s-%d", var.name, count.index+1) : var.name)}"
43
}
54

65
######
@@ -35,7 +34,7 @@ resource "aws_instance" "this" {
3534
placement_group = "${var.placement_group}"
3635
tenancy = "${var.tenancy}"
3736

38-
tags = "${merge(local.instance_name, var.tags)}"
37+
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)}"
3938

4039
lifecycle {
4140
# Due to several known issues in Terraform AWS provider related to arguments of aws_instance:
@@ -78,7 +77,7 @@ resource "aws_instance" "this_t2" {
7877
cpu_credits = "${var.cpu_credits}"
7978
}
8079

81-
tags = "${merge(local.instance_name, var.tags)}"
80+
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)}"
8281

8382
lifecycle {
8483
# Due to several known issues in Terraform AWS provider related to arguments of aws_instance:

0 commit comments

Comments
 (0)