[GH-ISSUE #95] Unhandled error: <class 'IndexError'>, list index out of range, <traceback object at 0x7fb55d6a3240> #46

Closed
opened 2026-05-06 12:36:41 +02:00 by BreizhHardware · 3 comments

Originally created by @SandipKumar05 on GitHub (Dec 23, 2023).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/95

I am getting issues while running this with my Terraform.

Checking for additional links between 48 resources..
   aws_subnet.private~1 --> aws_db_subnet_group.database-subnet-group
   aws_subnet.private~2 --> aws_db_subnet_group.database-subnet-group
   aws_subnet.public~1 --> aws_instance.bastion
   aws_subnet.public~2 --> aws_instance.bastion
   aws_subnet.private~1 --> aws_launch_template.api-launch-template
   aws_subnet.private~2 --> aws_launch_template.api-launch-template
   aws_subnet.private~1 --> aws_launch_template.web-launch-template
   aws_subnet.private~2 --> aws_launch_template.web-launch-template
   aws_subnet.public~1 --> aws_lb.application-load-balancer
   aws_subnet.public~2 --> aws_lb.application-load-balancer
   aws_vpc.this~1 --> aws_lb_target_group.api_target_group
   aws_vpc.this~1 --> aws_lb_target_group.web_target_group
   aws_vpc.this~1 --> aws_internet_gateway.this~1
   aws_nat_gateway.this~1 --> aws_eip.nat~1
   aws_nat_gateway.this~1 --> aws_internet_gateway.this~1
   aws_vpc.this~1 --> aws_route_table.private~1
   aws_vpc.this~1 --> aws_route_table.public~1
   aws_subnet.private~1 --> aws_route_table_association.private~1
   aws_route_table_association.private~1 --> aws_route_table.private~1
   aws_subnet.private~2 --> aws_route_table_association.private~2
   aws_subnet.public~1 --> aws_route_table_association.public~1
   aws_route_table_association.public~1 --> aws_route_table.public~1
   aws_subnet.public~2 --> aws_route_table_association.public~2
   aws_vpc.this~1 --> aws_subnet.private~1
   aws_vpc.this~1 --> aws_subnet.public~1
Unhandled error: <class 'IndexError'>, list index out of range, <traceback object at 0x7fb55d6a3240>

Vesion: aws-cli/2.15.2 Python/3.11.6 Linux/5.15.0-91-generic exe/x86_64.linuxmint.21
Terraform: v1.6.6

Originally created by @SandipKumar05 on GitHub (Dec 23, 2023). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/95 I am getting issues while running this with my Terraform. ``` Checking for additional links between 48 resources.. aws_subnet.private~1 --> aws_db_subnet_group.database-subnet-group aws_subnet.private~2 --> aws_db_subnet_group.database-subnet-group aws_subnet.public~1 --> aws_instance.bastion aws_subnet.public~2 --> aws_instance.bastion aws_subnet.private~1 --> aws_launch_template.api-launch-template aws_subnet.private~2 --> aws_launch_template.api-launch-template aws_subnet.private~1 --> aws_launch_template.web-launch-template aws_subnet.private~2 --> aws_launch_template.web-launch-template aws_subnet.public~1 --> aws_lb.application-load-balancer aws_subnet.public~2 --> aws_lb.application-load-balancer aws_vpc.this~1 --> aws_lb_target_group.api_target_group aws_vpc.this~1 --> aws_lb_target_group.web_target_group aws_vpc.this~1 --> aws_internet_gateway.this~1 aws_nat_gateway.this~1 --> aws_eip.nat~1 aws_nat_gateway.this~1 --> aws_internet_gateway.this~1 aws_vpc.this~1 --> aws_route_table.private~1 aws_vpc.this~1 --> aws_route_table.public~1 aws_subnet.private~1 --> aws_route_table_association.private~1 aws_route_table_association.private~1 --> aws_route_table.private~1 aws_subnet.private~2 --> aws_route_table_association.private~2 aws_subnet.public~1 --> aws_route_table_association.public~1 aws_route_table_association.public~1 --> aws_route_table.public~1 aws_subnet.public~2 --> aws_route_table_association.public~2 aws_vpc.this~1 --> aws_subnet.private~1 aws_vpc.this~1 --> aws_subnet.public~1 Unhandled error: <class 'IndexError'>, list index out of range, <traceback object at 0x7fb55d6a3240> ``` Vesion: aws-cli/2.15.2 Python/3.11.6 Linux/5.15.0-91-generic exe/x86_64.linuxmint.21 Terraform: v1.6.6
Author
Owner

@patrickchugh commented on GitHub (Dec 25, 2023):

Hi @SandipKumar05 Can you share the source Terraform so I can try to re-produce? Also, please add the --debug flag for terravision so it will show more error details. Please also ensure you are using latest code on main branch.

<!-- gh-comment-id:1869009470 --> @patrickchugh commented on GitHub (Dec 25, 2023): Hi @SandipKumar05 Can you share the source Terraform so I can try to re-produce? Also, please add the ``--debug`` flag for terravision so it will show more error details. Please also ensure you are using latest code on main branch.
Author
Owner

@benjcabalona1029 commented on GitHub (May 7, 2025):

Hi @patrickchugh I encountered similar error.

provider "aws" {
  region = "us-east-1"
}

# 1. Create VPC
# Enable DNS support and hostnames
resource "aws_vpc" "main" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_support   = true
  enable_dns_hostnames = true
}


# 2. Create 2 private subnets
resource "aws_subnet" "private_a" {
  vpc_id                  = aws_vpc.main.id
  cidr_block              = "10.0.1.0/24"
  availability_zone       = "us-east-1a"
  map_public_ip_on_launch = false
}

resource "aws_subnet" "private_b" {
  vpc_id                  = aws_vpc.main.id
  cidr_block              = "10.0.2.0/24"
  availability_zone       = "us-east-1b"
  map_public_ip_on_launch = false
}

# 3. Private route table
resource "aws_route_table" "private" {
  vpc_id = aws_vpc.main.id
}

# 4. Associate the 2 private subnets to the route table
resource "aws_route_table_association" "private_a" {
  subnet_id      = aws_subnet.private_a.id
  route_table_id = aws_route_table.private.id
}

resource "aws_route_table_association" "private_b" {
  subnet_id      = aws_subnet.private_b.id
  route_table_id = aws_route_table.private.id
}

# 5. VPC Endpoint to S3
resource "aws_vpc_endpoint" "s3" {
  vpc_id       = aws_vpc.main.id
  service_name = "com.amazonaws.us-east-1.s3"
  route_table_ids = [aws_route_table.private.id]
}

# 6. Security group for RDS
resource "aws_security_group" "rds" {
  name        = "rds-sg"
  description = "Allow MySQL and self-referencing"
  vpc_id      = aws_vpc.main.id

  ingress {
    from_port   = 3306
    to_port     = 3306
    protocol    = "tcp"
    cidr_blocks = ["10.0.0.0/16"]
  }

  ingress {
    from_port       = 0
    to_port         = 0
    protocol        = "-1"
    self            = true
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }
}

# 7. Subnet group for RDS
resource "aws_db_subnet_group" "rds" {
  name       = "rds-subnet-group"
  subnet_ids = [aws_subnet.private_a.id, aws_subnet.private_b.id]

  tags = {
    Name = "RDS subnet group"
  }
}

# 8. RDS instance
resource "aws_db_instance" "default" {
  identifier              = "mydb"
  engine                  = "mysql"
  engine_version          = "8.0"
  instance_class          = "db.t3.micro"
  allocated_storage       = 20
  username                = "admin"
  password                = "YourStrongPassword123!"
  db_subnet_group_name    = aws_db_subnet_group.rds.name
  vpc_security_group_ids  = [aws_security_group.rds.id]
  skip_final_snapshot     = true
  publicly_accessible     = false
}

# 9. Glue JDBC Connection
# Somehow I need to retype the password in the Glue Connection
resource "aws_glue_connection" "jdbc" {
  name = "rds-jdbc-connection"

  connection_properties = {
    JDBC_CONNECTION_URL = "jdbc:mysql://${aws_db_instance.default.address}:3306/mydb"
    USERNAME            = "admin"
    PASSWORD            = "YourStrongPassword123!"
  }

  physical_connection_requirements {
    subnet_id              = aws_subnet.private_a.id
    security_group_id_list = [aws_security_group.rds.id]
  }
}


output "vpc_id" {
  value       = aws_vpc.main.id
  description = "The ID of the main VPC"
}

output "private_subnet_ids" {
  value       = [aws_subnet.private_a.id, aws_subnet.private_b.id]
  description = "IDs of the private subnets"
}

output "rds_endpoint" {
  value       = aws_db_instance.default.endpoint
  description = "The endpoint address of the RDS instance"
}

output "rds_subnet_group" {
  value       = aws_db_subnet_group.rds.name
  description = "The name of the RDS subnet group"
}

output "glue_connection_name" {
  value       = aws_glue_connection.jdbc.name
  description = "The name of the Glue JDBC connection"
}

output "rds_security_group_id" {
  value       = aws_security_group.rds.id
  description = "The ID of the security group used by RDS"
}

This is the error when I run it in debug mode

Traceback (most recent call last):
  File "/terravision/./terravision", line 289, in <module>
    cli(
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/terravision/./terravision", line 207, in draw
    tfdata = compile_tfdata(source, varfile, workspace, debug, annotate)
  File "/terravision/./terravision", line 76, in compile_tfdata
    tfdata = graphmaker.handle_special_resources(tfdata)
  File "/terravision/modules/graphmaker.py", line 462, in handle_special_resources
    tfdata = getattr(resource_handlers, handler)(tfdata)
  File "/terravision/modules/resource_handlers.py", line 416, in aws_handle_dbsubnet
    vpc = helpers.list_of_parents(tfdata["graphdict"], az)[0]
IndexError: list index out of range
<!-- gh-comment-id:2856916094 --> @benjcabalona1029 commented on GitHub (May 7, 2025): Hi @patrickchugh I encountered similar error. ``` provider "aws" { region = "us-east-1" } # 1. Create VPC # Enable DNS support and hostnames resource "aws_vpc" "main" { cidr_block = "10.0.0.0/16" enable_dns_support = true enable_dns_hostnames = true } # 2. Create 2 private subnets resource "aws_subnet" "private_a" { vpc_id = aws_vpc.main.id cidr_block = "10.0.1.0/24" availability_zone = "us-east-1a" map_public_ip_on_launch = false } resource "aws_subnet" "private_b" { vpc_id = aws_vpc.main.id cidr_block = "10.0.2.0/24" availability_zone = "us-east-1b" map_public_ip_on_launch = false } # 3. Private route table resource "aws_route_table" "private" { vpc_id = aws_vpc.main.id } # 4. Associate the 2 private subnets to the route table resource "aws_route_table_association" "private_a" { subnet_id = aws_subnet.private_a.id route_table_id = aws_route_table.private.id } resource "aws_route_table_association" "private_b" { subnet_id = aws_subnet.private_b.id route_table_id = aws_route_table.private.id } # 5. VPC Endpoint to S3 resource "aws_vpc_endpoint" "s3" { vpc_id = aws_vpc.main.id service_name = "com.amazonaws.us-east-1.s3" route_table_ids = [aws_route_table.private.id] } # 6. Security group for RDS resource "aws_security_group" "rds" { name = "rds-sg" description = "Allow MySQL and self-referencing" vpc_id = aws_vpc.main.id ingress { from_port = 3306 to_port = 3306 protocol = "tcp" cidr_blocks = ["10.0.0.0/16"] } ingress { from_port = 0 to_port = 0 protocol = "-1" self = true } egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } } # 7. Subnet group for RDS resource "aws_db_subnet_group" "rds" { name = "rds-subnet-group" subnet_ids = [aws_subnet.private_a.id, aws_subnet.private_b.id] tags = { Name = "RDS subnet group" } } # 8. RDS instance resource "aws_db_instance" "default" { identifier = "mydb" engine = "mysql" engine_version = "8.0" instance_class = "db.t3.micro" allocated_storage = 20 username = "admin" password = "YourStrongPassword123!" db_subnet_group_name = aws_db_subnet_group.rds.name vpc_security_group_ids = [aws_security_group.rds.id] skip_final_snapshot = true publicly_accessible = false } # 9. Glue JDBC Connection # Somehow I need to retype the password in the Glue Connection resource "aws_glue_connection" "jdbc" { name = "rds-jdbc-connection" connection_properties = { JDBC_CONNECTION_URL = "jdbc:mysql://${aws_db_instance.default.address}:3306/mydb" USERNAME = "admin" PASSWORD = "YourStrongPassword123!" } physical_connection_requirements { subnet_id = aws_subnet.private_a.id security_group_id_list = [aws_security_group.rds.id] } } output "vpc_id" { value = aws_vpc.main.id description = "The ID of the main VPC" } output "private_subnet_ids" { value = [aws_subnet.private_a.id, aws_subnet.private_b.id] description = "IDs of the private subnets" } output "rds_endpoint" { value = aws_db_instance.default.endpoint description = "The endpoint address of the RDS instance" } output "rds_subnet_group" { value = aws_db_subnet_group.rds.name description = "The name of the RDS subnet group" } output "glue_connection_name" { value = aws_glue_connection.jdbc.name description = "The name of the Glue JDBC connection" } output "rds_security_group_id" { value = aws_security_group.rds.id description = "The ID of the security group used by RDS" } ``` This is the error when I run it in debug mode ``` Traceback (most recent call last): File "/terravision/./terravision", line 289, in <module> cli( File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/terravision/./terravision", line 207, in draw tfdata = compile_tfdata(source, varfile, workspace, debug, annotate) File "/terravision/./terravision", line 76, in compile_tfdata tfdata = graphmaker.handle_special_resources(tfdata) File "/terravision/modules/graphmaker.py", line 462, in handle_special_resources tfdata = getattr(resource_handlers, handler)(tfdata) File "/terravision/modules/resource_handlers.py", line 416, in aws_handle_dbsubnet vpc = helpers.list_of_parents(tfdata["graphdict"], az)[0] IndexError: list index out of range ```
Author
Owner

@patrickchugh commented on GitHub (Dec 16, 2025):

Fixed with latest version

<!-- gh-comment-id:3662723856 --> @patrickchugh commented on GitHub (Dec 16, 2025): Fixed with latest version
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/terravision#46
No description provided.