Skip to content

Commit

Permalink
fix count variables are only valid within resources (terraform-aws-mo…
Browse files Browse the repository at this point in the history
…dules#72)

Signed-off-by: Denis Iskandarov <[email protected]>
  • Loading branch information
den-is authored and antonbabenko committed Feb 27, 2019
1 parent ac02252 commit c682cc3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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)}"
}

######
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c682cc3

Please sign in to comment.