[GH-ISSUE #140] failing with KeyError: 'module.rds.aws_security_group.rds_sg #80

Closed
opened 2026-05-06 12:37:12 +02:00 by BreizhHardware · 0 comments

Originally created by @VecnaLarry on GitHub (Apr 30, 2025).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/140

running using "terravision draw --source . --workspace staging --varfile s/env-variables.tfvars --debug"

Checking for additional links between 365 resources.. module.rds.aws_db_instance.db["bl-camunda-be-rds"][bl-camunda-be-rds] --> module.rds.aws_db_subnet_group.rds_subnet_group Traceback (most recent call last): File "/other/tools/terravision/terravision", line 289, in <module> cli( File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/other/tools/terravision/terravision", line 207, in draw tfdata = compile_tfdata(source, varfile, workspace, debug, annotate) File "/other/tools/terravision/terravision", line 72, in compile_tfdata tfdata = graphmaker.consolidate_nodes(tfdata) File "/other/tools/terravision/modules/graphmaker.py", line 208, in consolidate_nodes resdata = tfdata["meta_data"][resource] KeyError: 'module.rds.aws_security_group.rds_sg["bl-dynaview-rds"][bl-dynaview-rds]'

Seems like the code it's having trouble with is this the last part of this:

resource "aws_db_instance" "db" {
   for_each = { for db in var.db_instances : db.identifier => db }
 
   identifier              = "${var.environment}-${each.value.identifier}"
   instance_class          = each.value.size
   engine                  = each.value.engine
   engine_version          = each.value.engine_version
   allocated_storage       = each.value.storage_gb
   max_allocated_storage   = each.value.max_storage_gb
   storage_type            = "gp3"
   storage_encrypted       = true
   kms_key_id              = var.kms_key_rds_arn
   multi_az                = false
   deletion_protection     = false
   skip_final_snapshot     = true
   apply_immediately       = true
 
   # Performance Insights
   performance_insights_enabled = true
   performance_insights_kms_key_id = var.kms_key_rds_arn
   performance_insights_retention_period = 7
 
   # IAM authentication
   iam_database_authentication_enabled = true
 
   # Credentials pulled from Secrets Manager
   username = each.value.username
   password = random_password.db_password[each.key].result
 
   # Autoscaling
   auto_minor_version_upgrade = true
 
   vpc_security_group_ids = [aws_security_group.rds_sg[each.key].id]
   db_subnet_group_name   = aws_db_subnet_group.rds_subnet_group.name
 
   depends_on = [aws_secretsmanager_secret_version.db_secret_version]
 }

Originally created by @VecnaLarry on GitHub (Apr 30, 2025). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/140 running using "terravision draw --source . --workspace staging --varfile s/env-variables.tfvars --debug" `Checking for additional links between 365 resources.. module.rds.aws_db_instance.db["bl-camunda-be-rds"][bl-camunda-be-rds] --> module.rds.aws_db_subnet_group.rds_subnet_group Traceback (most recent call last): File "/other/tools/terravision/terravision", line 289, in <module> cli( File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__ return self.main(*args, **kwargs) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/lprikockis/.local/lib/python3.10/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/other/tools/terravision/terravision", line 207, in draw tfdata = compile_tfdata(source, varfile, workspace, debug, annotate) File "/other/tools/terravision/terravision", line 72, in compile_tfdata tfdata = graphmaker.consolidate_nodes(tfdata) File "/other/tools/terravision/modules/graphmaker.py", line 208, in consolidate_nodes resdata = tfdata["meta_data"][resource] KeyError: 'module.rds.aws_security_group.rds_sg["bl-dynaview-rds"][bl-dynaview-rds]' ` Seems like the code it's having trouble with is this the last part of this: ``` resource "aws_db_instance" "db" { for_each = { for db in var.db_instances : db.identifier => db } identifier = "${var.environment}-${each.value.identifier}" instance_class = each.value.size engine = each.value.engine engine_version = each.value.engine_version allocated_storage = each.value.storage_gb max_allocated_storage = each.value.max_storage_gb storage_type = "gp3" storage_encrypted = true kms_key_id = var.kms_key_rds_arn multi_az = false deletion_protection = false skip_final_snapshot = true apply_immediately = true # Performance Insights performance_insights_enabled = true performance_insights_kms_key_id = var.kms_key_rds_arn performance_insights_retention_period = 7 # IAM authentication iam_database_authentication_enabled = true # Credentials pulled from Secrets Manager username = each.value.username password = random_password.db_password[each.key].result # Autoscaling auto_minor_version_upgrade = true vpc_security_group_ids = [aws_security_group.rds_sg[each.key].id] db_subnet_group_name = aws_db_subnet_group.rds_subnet_group.name depends_on = [aws_secretsmanager_secret_version.db_secret_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#80
No description provided.