Difference between revisions of "Each."

From wikieduonline
Jump to navigation Jump to search
Line 13: Line 13:
 
   
 
   
 
  data "aws_subnet" "all_db" {
 
  data "aws_subnet" "all_db" {
   for_each = toset(data.aws_subnets.all_db.ids)
+
   [[for_each]] = toset(data.aws_subnets.all_db.ids)
 
   id      = each.value
 
   id      = each.value
 
  }
 
  }

Revision as of 18:00, 14 May 2023

data "aws_subnets" "all_db" {
 filter {
   name   = "vpc-id"
   values = [var.vpc_id]
 }

 tags = {
   Tier = "DB"
 }
} 

data "aws_subnet" "all_db" {
 for_each = toset(data.aws_subnets.all_db.ids)
 id       = each.value
}


data "aws_subnets" "all_app" {
 filter {
   name   = "vpc-id"
   values = [var.vpc_id]
 }

 tags = {
   Tier = "WebApp"
 }
}

data "aws_subnet" "all_app" {
 for_each = toset(data.aws_subnets.all_app.ids)
 id       = each.value
}

See also

Advertising: