From 78dcfafcb15eaa0d57b7a57256798b0a5f3dea3c Mon Sep 17 00:00:00 2001 From: Shayan Ghani <102943333+Shayan-Ghani@users.noreply.github.com> Date: Tue, 4 Jul 2023 10:16:32 +0330 Subject: [PATCH] change the absolute count number "4" to the length of env_name variable changed the absolute count number to env_name length to avoid corruption if another environment gets added or removed. --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index ba39f3b..8404a74 100644 --- a/main.tf +++ b/main.tf @@ -4,7 +4,7 @@ resource "aws_instance" "babak" { ami = var.ami_id instance_type = var.instance_type key_name = var.key_name - count = 4 + count = length(var.env_name) tags = { Name = "babak-${var.env_name[count.index]}" Created_By = local.created_by @@ -49,4 +49,4 @@ resource "aws_instance" "babak" { # Name = "babak2" # } -# } \ No newline at end of file +# }