Skip to content

Commit

Permalink
Added locals
Browse files Browse the repository at this point in the history
  • Loading branch information
qtsathish committed Mar 2, 2021
1 parent 04aca88 commit 7380061
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Feb21/ntier-tf-aws/locals.tf
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
subnets = ["web1", "web2", "app1", "app2", "db1", "db2"]
}
2 changes: 1 addition & 1 deletion Feb21/ntier-tf-aws/main.tf
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_subnet" "subnets" {
availability_zone = "${var.region}${count.index%2 == 0?"a":"b"}" availability_zone = "${var.region}${count.index%2 == 0?"a":"b"}"


tags = { tags = {
"Name" = var.subnets[count.index] "Name" = local.subnets[count.index]
} }


depends_on = [ depends_on = [
Expand Down
7 changes: 2 additions & 5 deletions Feb21/ntier-tf-aws/variables.tf
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ variable "region" {
variable "vpccidr" { variable "vpccidr" {
type = string type = string
default = "192.168.0.0/16" default = "192.168.0.0/16"
description = "cidr range of the vpc"
} }


variable "subnets" {
type = list(string)
default = ["web1", "web2", "app1", "app2", "db1", "db2"]
description = "Name of the subnets"
}

0 comments on commit 7380061

Please sign in to comment.