[GH-ISSUE #172] not working with --planfile #101

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

Originally created by @gchan122sage on GitHub (Mar 5, 2026).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/172

Originally assigned to: @patrickchugh on GitHub.

Hi nice work, I ran into issue when running with planfile, my tfvars and variables file are symlinks, Get the following error when using running:


docker run --rm -it -v $root_folder:/project patrickchugh/terravision 
draw --planfile "/project/environments/$ENVIRONMENT/$STACK/plan.json" 
--graphfile "/project/environments/$ENVIRONMENT/$STACK/graph.dot" 
--source "/project/environments/$ENVIRONMENT/$STACK" 
--outfile "/project/environments/$ENVIRONMENT/$STACK/diagram" 
--debug

Preflight check..
  dot command detected: /usr/bin/dot
  gvpr command detected: /usr/bin/gvpr
  git command detected: /usr/bin/git
  terraform command detected: /usr/local/bin/terraform
  terraform version detected: Terraform v1.10.5



Using pre-generated plan and graph files. No Terraform commands will be executed.

Converting TF Graph Connections..


Parsing Terraform Source Files..
  Added Source Location: /project/environments/management/nessus-scanner
  Parsing /project/environments/management/nessus-scanner/main.tf
    Found 1 locals stanza(s)
    Found 7 resource stanza(s)
    Found 4 data stanza(s)
  Parsing /project/environments/management/nessus-scanner/management.auto.tfvars
  Parsing /project/environments/management/nessus-scanner/terraform.tf
    Found 1 data stanza(s)
    Found 2 provider stanza(s)
  Parsing /project/environments/management/nessus-scanner/variables.tf
    Found 8 variable stanza(s)
  Will use auto variables from file : /project/environments/management/nessus-scanner/management.auto.tfvars 

Traceback (most recent call last):
  File "/home/terravision/.local/bin/terravision", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 1116, in main
    cli(
  File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1485, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1406, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1873, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1269, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 824, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 969, in draw
    tfdata = compile_tfdata(
             ^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 522, in compile_tfdata
    tfdata = _process_pregenerated_source(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 415, in _process_pregenerated_source
    tfdata = fileparser.read_tfsource(codepath_list, [], annotate, tfdata)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/terravision/.local/lib/python3.12/site-packages/modules/fileparser.py", line 395, in read_tfsource
    varfile_list = varfile_list + (file,)
                   ~~~~~~~~~~~~~^~~~~~~~~
TypeError: can only concatenate list (not "tuple") to list

After modifying the fileparser.py file seems to be working.

Image
docker run --rm -it 
-v $root_folder/fileparser.py:/home/terravision/.local/lib/python3.12/site-packages/modules/fileparser.py 
-v $root_folder:/project patrickchugh/terravision draw 
--planfile "/project/environments/$ENVIRONMENT/$STACK/plan.json" 
--graphfile "/project/environments/$ENVIRONMENT/$STACK/graph.dot" 
--source "/project/environments/$ENVIRONMENT/$STACK" 
--outfile "/project/environments/$ENVIRONMENT/$STACK/diagram" 
--debug

Preflight check..
  dot command detected: /usr/bin/dot
  gvpr command detected: /usr/bin/gvpr
  git command detected: /usr/bin/git
  terraform command detected: /usr/local/bin/terraform
  terraform version detected: Terraform v1.10.5



Using pre-generated plan and graph files. No Terraform commands will be executed.

Converting TF Graph Connections..


Parsing Terraform Source Files..
  Added Source Location: /project/environments/management/nessus-scanner
  Parsing /project/environments/management/nessus-scanner/main.tf
    Found 1 locals stanza(s)
    Found 7 resource stanza(s)
    Found 4 data stanza(s)
  Parsing /project/environments/management/nessus-scanner/management.auto.tfvars
  Parsing /project/environments/management/nessus-scanner/terraform.tf
    Found 1 data stanza(s)
    Found 2 provider stanza(s)
  Parsing /project/environments/management/nessus-scanner/variables.tf
    Found 8 variable stanza(s)
  Will use auto variables from file : /project/environments/management/nessus-scanner/management.auto.tfvars 


INFO: Debug flag used. Current state has been written to /project/tfdata.json


Detected cloud provider: AWS (5 resources)


Terraform JSON graph dictionary:

{
    "aws_instance.nessus_scanner": [
        "aws_lb_target_group_attachment.nessus_scanner",
        "dns_a_record_set.nessus_ssh"
    ],
    "aws_lb_listener_rule.nessus_scanner": [],
    "aws_lb_target_group.nessus_scanner": [
        "aws_lb_listener_rule.nessus_scanner",
        "aws_lb_target_group_attachment.nessus_scanner"
    ],
    "aws_lb_target_group_attachment.nessus_scanner": [],
    "aws_security_group.nessus_scanner": [
        "aws_instance.nessus_scanner"
    ],
    "dns_a_record_set.nessus_ssh": [],
    "dns_cname_record.nessus_web": []
}

Processing variables..

Processing resources..
   aws_instance.nessus_scanner
   aws_lb_listener_rule.nessus_scanner
   aws_lb_target_group.nessus_scanner
   aws_lb_target_group_attachment.nessus_scanner
   aws_security_group.nessus_scanner
   dns_a_record_set.nessus_ssh
   dns_cname_record.nessus_web

  Locals list :
    /main: nessus_ingress_ports

  Module list :

  Resource list :
    nessus-scanner/main.tf: aws_instance.nessus_scanner
    nessus-scanner/main.tf: dns_a_record_set.nessus_ssh
    nessus-scanner/main.tf: dns_cname_record.nessus_web
    nessus-scanner/main.tf: aws_security_group.nessus_scanner
    nessus-scanner/main.tf: aws_lb_target_group.nessus_scanner
    nessus-scanner/main.tf: aws_lb_target_group_attachment.nessus_scanner
    nessus-scanner/main.tf: aws_lb_listener_rule.nessus_scanner

  Data list :
    nessus-scanner/main.tf: aws_ami.nessus_byol
    nessus-scanner/main.tf: aws_subnet.private_subnet
    nessus-scanner/main.tf: aws_lb.alb_private_mgmt
    nessus-scanner/main.tf: aws_lb_listener.https
    nessus-scanner/terraform.tf: aws_secretsmanager_secret_version.ad_dns

  Output list :

  Variable List:

    Module: main
      var.aws_region = "us-east-1"
      var.alerts_sns_arn = "arn:aws:sns:us-east-1:974266546473:alerts"
      var.account_name = management
      var.account_id = 974266546473
      var.env = mgmt
      var.vpc_id = vpc-06da1b20f2dfbe67f
      var.peered_vpcs_prefix_list_id = pl-0e80014acd13bf474
      var.vpn_users_prefix_list_id = pl-09373700b9c39760f

Checking for additional links between 7 resources..
   aws_instance.nessus_scanner --> aws_security_group.nessus_scanner
   aws_lb_listener_rule.nessus_scanner --> aws_lb_target_group.nessus_scanner
   aws_lb_target_group_attachment.nessus_scanner --> aws_lb_target_group.nessus_scanner
   aws_lb_target_group_attachment.nessus_scanner --> aws_instance.nessus_scanner
   dns_a_record_set.nessus_ssh --> aws_instance.nessus_scanner

Enriched graphviz dictionary:

{
    "False.elb": [
        "aws_instance.nessus_scanner"
    ],
    "aws_group.shared_services": [
        "aws_iam_group.of_services"
    ],
    "aws_instance.nessus_scanner": [],
    "aws_lb.elb": [
        "False.elb"
    ],
    "dns_a_record_set.nessus_ssh": [
        "aws_instance.nessus_scanner"
    ],
    "dns_cname_record.nessus_web": []
}

Rendering Architecture Image...
  Output file: /project/environments/management/nessus-scanner/diagram.dot.png
  Completed!
Originally created by @gchan122sage on GitHub (Mar 5, 2026). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/172 Originally assigned to: @patrickchugh on GitHub. Hi nice work, I ran into issue when running with planfile, my tfvars and variables file are symlinks, Get the following error when using running: ``` docker run --rm -it -v $root_folder:/project patrickchugh/terravision draw --planfile "/project/environments/$ENVIRONMENT/$STACK/plan.json" --graphfile "/project/environments/$ENVIRONMENT/$STACK/graph.dot" --source "/project/environments/$ENVIRONMENT/$STACK" --outfile "/project/environments/$ENVIRONMENT/$STACK/diagram" --debug Preflight check.. dot command detected: /usr/bin/dot gvpr command detected: /usr/bin/gvpr git command detected: /usr/bin/git terraform command detected: /usr/local/bin/terraform terraform version detected: Terraform v1.10.5 Using pre-generated plan and graph files. No Terraform commands will be executed. Converting TF Graph Connections.. Parsing Terraform Source Files.. Added Source Location: /project/environments/management/nessus-scanner Parsing /project/environments/management/nessus-scanner/main.tf Found 1 locals stanza(s) Found 7 resource stanza(s) Found 4 data stanza(s) Parsing /project/environments/management/nessus-scanner/management.auto.tfvars Parsing /project/environments/management/nessus-scanner/terraform.tf Found 1 data stanza(s) Found 2 provider stanza(s) Parsing /project/environments/management/nessus-scanner/variables.tf Found 8 variable stanza(s) Will use auto variables from file : /project/environments/management/nessus-scanner/management.auto.tfvars Traceback (most recent call last): File "/home/terravision/.local/bin/terravision", line 8, in <module> sys.exit(main()) ^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 1116, in main cli( File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1485, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1406, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1873, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 1269, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/click/core.py", line 824, in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 969, in draw tfdata = compile_tfdata( ^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 522, in compile_tfdata tfdata = _process_pregenerated_source( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/terravision/terravision.py", line 415, in _process_pregenerated_source tfdata = fileparser.read_tfsource(codepath_list, [], annotate, tfdata) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/terravision/.local/lib/python3.12/site-packages/modules/fileparser.py", line 395, in read_tfsource varfile_list = varfile_list + (file,) ~~~~~~~~~~~~~^~~~~~~~~ TypeError: can only concatenate list (not "tuple") to list ``` After modifying the fileparser.py file seems to be working. <img width="1360" height="230" alt="Image" src="https://github.com/user-attachments/assets/df1c2cd2-c12f-4cb6-8692-2874cf767612" /> ``` docker run --rm -it -v $root_folder/fileparser.py:/home/terravision/.local/lib/python3.12/site-packages/modules/fileparser.py -v $root_folder:/project patrickchugh/terravision draw --planfile "/project/environments/$ENVIRONMENT/$STACK/plan.json" --graphfile "/project/environments/$ENVIRONMENT/$STACK/graph.dot" --source "/project/environments/$ENVIRONMENT/$STACK" --outfile "/project/environments/$ENVIRONMENT/$STACK/diagram" --debug Preflight check.. dot command detected: /usr/bin/dot gvpr command detected: /usr/bin/gvpr git command detected: /usr/bin/git terraform command detected: /usr/local/bin/terraform terraform version detected: Terraform v1.10.5 Using pre-generated plan and graph files. No Terraform commands will be executed. Converting TF Graph Connections.. Parsing Terraform Source Files.. Added Source Location: /project/environments/management/nessus-scanner Parsing /project/environments/management/nessus-scanner/main.tf Found 1 locals stanza(s) Found 7 resource stanza(s) Found 4 data stanza(s) Parsing /project/environments/management/nessus-scanner/management.auto.tfvars Parsing /project/environments/management/nessus-scanner/terraform.tf Found 1 data stanza(s) Found 2 provider stanza(s) Parsing /project/environments/management/nessus-scanner/variables.tf Found 8 variable stanza(s) Will use auto variables from file : /project/environments/management/nessus-scanner/management.auto.tfvars INFO: Debug flag used. Current state has been written to /project/tfdata.json Detected cloud provider: AWS (5 resources) Terraform JSON graph dictionary: { "aws_instance.nessus_scanner": [ "aws_lb_target_group_attachment.nessus_scanner", "dns_a_record_set.nessus_ssh" ], "aws_lb_listener_rule.nessus_scanner": [], "aws_lb_target_group.nessus_scanner": [ "aws_lb_listener_rule.nessus_scanner", "aws_lb_target_group_attachment.nessus_scanner" ], "aws_lb_target_group_attachment.nessus_scanner": [], "aws_security_group.nessus_scanner": [ "aws_instance.nessus_scanner" ], "dns_a_record_set.nessus_ssh": [], "dns_cname_record.nessus_web": [] } Processing variables.. Processing resources.. aws_instance.nessus_scanner aws_lb_listener_rule.nessus_scanner aws_lb_target_group.nessus_scanner aws_lb_target_group_attachment.nessus_scanner aws_security_group.nessus_scanner dns_a_record_set.nessus_ssh dns_cname_record.nessus_web Locals list : /main: nessus_ingress_ports Module list : Resource list : nessus-scanner/main.tf: aws_instance.nessus_scanner nessus-scanner/main.tf: dns_a_record_set.nessus_ssh nessus-scanner/main.tf: dns_cname_record.nessus_web nessus-scanner/main.tf: aws_security_group.nessus_scanner nessus-scanner/main.tf: aws_lb_target_group.nessus_scanner nessus-scanner/main.tf: aws_lb_target_group_attachment.nessus_scanner nessus-scanner/main.tf: aws_lb_listener_rule.nessus_scanner Data list : nessus-scanner/main.tf: aws_ami.nessus_byol nessus-scanner/main.tf: aws_subnet.private_subnet nessus-scanner/main.tf: aws_lb.alb_private_mgmt nessus-scanner/main.tf: aws_lb_listener.https nessus-scanner/terraform.tf: aws_secretsmanager_secret_version.ad_dns Output list : Variable List: Module: main var.aws_region = "us-east-1" var.alerts_sns_arn = "arn:aws:sns:us-east-1:974266546473:alerts" var.account_name = management var.account_id = 974266546473 var.env = mgmt var.vpc_id = vpc-06da1b20f2dfbe67f var.peered_vpcs_prefix_list_id = pl-0e80014acd13bf474 var.vpn_users_prefix_list_id = pl-09373700b9c39760f Checking for additional links between 7 resources.. aws_instance.nessus_scanner --> aws_security_group.nessus_scanner aws_lb_listener_rule.nessus_scanner --> aws_lb_target_group.nessus_scanner aws_lb_target_group_attachment.nessus_scanner --> aws_lb_target_group.nessus_scanner aws_lb_target_group_attachment.nessus_scanner --> aws_instance.nessus_scanner dns_a_record_set.nessus_ssh --> aws_instance.nessus_scanner Enriched graphviz dictionary: { "False.elb": [ "aws_instance.nessus_scanner" ], "aws_group.shared_services": [ "aws_iam_group.of_services" ], "aws_instance.nessus_scanner": [], "aws_lb.elb": [ "False.elb" ], "dns_a_record_set.nessus_ssh": [ "aws_instance.nessus_scanner" ], "dns_cname_record.nessus_web": [] } Rendering Architecture Image... Output file: /project/environments/management/nessus-scanner/diagram.dot.png Completed! ```
Author
Owner

@patrickchugh commented on GitHub (Mar 6, 2026):

Thanks for bringing this to my attention. Would you be able to share the tfdata.json so I can debug the issue with the load balancer name and type ? It's showing as false in your case.

<!-- gh-comment-id:4013324061 --> @patrickchugh commented on GitHub (Mar 6, 2026): Thanks for bringing this to my attention. Would you be able to share the tfdata.json so I can debug the issue with the load balancer name and type ? It's showing as false in your case.
Author
Owner

@gchan122sage commented on GitHub (Mar 6, 2026):

Alb and subnet is from data source, vpc is from tfvars. I also could not get it to draw the network components.

data "aws_lb" "alb_private_mgmt" {
 name = "alb-private-mgmt"  
}
data "aws_subnet" "private_subnet" {
 tags = { Name = "private-subnet-b" }
}
Image

tfdata.json

<!-- gh-comment-id:4013835115 --> @gchan122sage commented on GitHub (Mar 6, 2026): Alb and subnet is from data source, vpc is from tfvars. I also could not get it to draw the network components. ``` data "aws_lb" "alb_private_mgmt" { name = "alb-private-mgmt" } data "aws_subnet" "private_subnet" { tags = { Name = "private-subnet-b" } } ``` <img width="2688" height="1787" alt="Image" src="https://github.com/user-attachments/assets/7e4374ae-0f38-457f-b254-065b7c6bf016" /> [tfdata.json](https://github.com/user-attachments/files/25803452/tfdata.json)
Author
Owner

@patrickchugh commented on GitHub (Mar 7, 2026):

@gchan122sage Can you do a git pull and try again with the latest code? You should see something like:

Image

<!-- gh-comment-id:4016844522 --> @patrickchugh commented on GitHub (Mar 7, 2026): @gchan122sage Can you do a git pull and try again with the latest code? You should see something like: ![Image](https://github.com/user-attachments/assets/4a848283-a4ff-475d-9f07-aa6dbc3a02e8)
Author
Owner

@gchan122sage commented on GitHub (Mar 7, 2026):

I build a new image with the latest code and its working, this is good. A nice to have feature would an option for more detailed network like IPs, SG rules, ALB listener rules etc. Thanks.

<!-- gh-comment-id:4017169309 --> @gchan122sage commented on GitHub (Mar 7, 2026): I build a new image with the latest code and its working, this is good. A nice to have feature would an option for more detailed network like IPs, SG rules, ALB listener rules etc. Thanks.
Author
Owner

@patrickchugh commented on GitHub (Mar 8, 2026):

@gchan122sage Good idea, where would be the ideal place to put all that info ?
In a previous version I had each Subnet and VPC with the CIDR next to the label. Not sure about where rules and other info should go? You mean in a seperate table?

<!-- gh-comment-id:4018861267 --> @patrickchugh commented on GitHub (Mar 8, 2026): @gchan122sage Good idea, where would be the ideal place to put all that info ? In a previous version I had each Subnet and VPC with the CIDR next to the label. Not sure about where rules and other info should go? You mean in a seperate table?
Author
Owner

@gchan122sage commented on GitHub (Mar 9, 2026):

@patrickchugh I think a good place would be following the logic flow links ie: ALB -> listener and maybe a separate table to list details. Network info next to the label looks good.

<!-- gh-comment-id:4024277300 --> @gchan122sage commented on GitHub (Mar 9, 2026): @patrickchugh I think a good place would be following the logic flow links ie: ALB -> listener and maybe a separate table to list details. Network info next to the label looks good.
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#101
No description provided.