patrickchugh / terravision

Terravision creates Professional Cloud Architecture Diagrams from your Terraform code automatically. Supports AWS, Google and Azure.
Mozilla Public License 2.0
683 stars 67 forks source link

Unhandled error: <class 'TypeError'>, unsupported operand type(s) for +: 'bool' and 'str', <traceback object at 0x1065cab40> #82

Closed thiagoalexandria closed 7 months ago

thiagoalexandria commented 7 months ago

Problem Description

When running the terravision draw command in a local directory containing Terraform code, an unhandled error is triggered:

Unhandled error: <class 'TypeError'>, unsupported operand type(s) for +: 'bool' and 'str', <traceback object at 0x1065cab40>

Context

Command Executed: terravision draw Environment: Python 3.9.6 Terravision Version: 0.5 Terraform Version: v1.4.6

Steps to Reproduce

Access the directory with the Terraform code. Run the terravision draw command. Observe the mentioned error.

Expected Behavior

The terravision draw command was expected to execute correctly without generating errors related to unsupported operand types between data types.

Additional Notes

Unprocessed terraform graph dictionary:

{
    "aws_instance.webserver": [
        "aws_lb_target_group_attachment.name"
    ],
    "aws_lb.nginx": [
        "aws_lb_listener.name"
    ],
    "aws_lb_listener.name": [],
    "aws_lb_target_group.nginx": [
        "aws_lb_listener.name",
        "aws_lb_target_group_attachment.name"
    ],
    "aws_lb_target_group_attachment.name": [],
    "aws_security_group.allow_http": [
        "aws_instance.webserver",
        "aws_lb.nginx"
    ]
}

Parsing Terraform Source Files..
  Added Source Location: .
  Parsing ./data.tf
    Found 3 data stanza(s)
  Parsing ./main.tf
    Found 2 module stanza(s)
  Added Source Location: /Users/thiagoalexandria/Documents/Projetos/Terraform/aws_tf_estudos/modules/two-tier
  Added Source Location: /Users/thiagoalexandria/Documents/Projetos/Terraform/aws_tf_estudos/modules/two-tier
  Parsing ./variables.tf
  Parsing /Users/thiagoalexandria/Documents/Projetos/Terraform/aws_tf_estudos/modules/two-tier/output.tf
  Parsing /Users/thiagoalexandria/Documents/Projetos/Terraform/aws_tf_estudos/modules/two-tier/ec2.tf
    Found 2 resource stanza(s)
  Parsing /Users/thiagoalexandria/Documents/Projetos/Terraform/aws_tf_estudos/modules/two-tier/variables.tf
    Found 8 variable stanza(s)
  Parsing /Users/thiagoalexandria/Documents/Projetos/Terraform/aws_tf_estudos/modules/two-tier/alb.tf
    Found 4 resource stanza(s)

Processing variables..

Processing resources..

Checking for additional links between 6 resources..

Conditional resource list:
Unhandled error: <class 'TypeError'>, unsupported operand type(s) for +: 'bool' and 'str', <traceback object at 0x1065cab40>
rodrigo-segui commented 7 months ago

I'm also having this problem. Can anyone help?

patrickchugh commented 7 months ago

@rodrigo-segui @thiagoalexandria Can you try to do a git pull with the latest code and see if this is fixed? If not please supply some sample source so I can try to reproduce the error. Thanks!

thiagoalexandria commented 7 months ago

I'm facing the same error, @patrickchugh it generates the plan, reads it, but when it reaches the Conditional resource list stage, it fails with an error indicated in the issue:

Unhandled error: <class 'TypeError'>, unsupported operand type(s) for +: 'bool' and 'str', <traceback object at 0x108641880>

Here's the link to the repository with the code I'm testing.

https://github.com/thiagoalexandria/terravision-example

patrickchugh commented 7 months ago

@thiagoalexandria I fixed it and was able to get this to run when I tagged some subnets. Please download the latest code and try again.

Enriched graphviz dictionary:

{
    "aws_instance.webserver": [
        "aws_lb.elb"
    ],
    "aws_lb.elb": [
        "aws_alb.elb"
    ],
    "aws_security_group.allow_http": [
        "aws_instance.webserver",
        "aws_lb.elb"
    ]
}

Output JSON Dictionary :
{
    "aws_instance.webserver": [
        "aws_lb.elb"
    ],
    "aws_lb.elb": [
        "aws_alb.elb"
    ],
    "aws_security_group.allow_http": [
        "aws_instance.webserver",
        "aws_lb.elb"
    ]
}

Exporting graph object into file architecture.json

Completed!
thiagoalexandria commented 7 months ago

Now it works, thanks a lot !