Skip to content

Instantly share code, notes, and snippets.

@magickatt
Last active July 19, 2019 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magickatt/a499931fa87f20e60a4cbab96c512103 to your computer and use it in GitHub Desktop.
Save magickatt/a499931fa87f20e60a4cbab96c512103 to your computer and use it in GitHub Desktop.
Iterate over set for resource using count and index in Terraform
resource "aws_route" "transit_gateway_private_subnet_route" {
count = length(data.aws_route_tables.private_subnet.ids)
route_table_id = tolist(data.aws_route_tables.private_subnet.ids)[count.index]
destination_cidr_block = var.destination_cidr_block
transit_gateway_id = var.transit_gateway_id
}
data "aws_route_tables" "private_subnet" {
vpc_id = var.vpc_id
tags = {
subnet_purpose = "private"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment