Skip to content

[BUG] Module fails when subnet with unassociated rt is specified in (this|peer)_subnet_ids variable #108

@herrbpl

Description

@herrbpl

Describe the bug
When user specifies any subnet that is not associated with route table in vpc as value in variables:

  • peer_subnets_ids
  • this_subnet_ids

then module is unable to find route tables for these subnets and fails to peer vpcs

Terraform version: 1.5.6

Module version: 6.0.0

Error message:

Error: query returned no results. Please change your search criteria and try again
│ 
│   with module.partial_subnets.data.aws_route_table.peer_subnet_rts[0],

Terraform code that produces the error:

module "partial_subnets" {
  
  source  = "../../"
  #version = "6.0.0"

  providers = {
    aws.this = aws.this
    aws.peer = aws.peer
  }

  this_vpc_id = var.this_vpc_id
  peer_vpc_id = var.peer_vpc_id

  auto_accept_peering = true
  peer_dns_resolution = true
  this_dns_resolution = true  
  peer_subnets_ids = ["subnet-unassociated-with-any-rt", "subnet-associated-with-rt-x"]
  this_subnets_ids = var.this_subnets_ids
  this_rts_ids = var.this_rts_ids
  peer_rts_ids = ["peer_main_rt", "peer_rt-x"]

  tags = {
    Name        = "tf-partial-subnets"
    Environment = "Test"
  }
  
}

Additional context
Will provide a fix via PR

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions