patrickchugh / terravision

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

Unhandled error: <class 'KeyError'>, 'aws_cloudfront_distribution.docs_bucket_distribution' #134

Open felipeyoneharatw opened 1 month ago

felipeyoneharatw commented 1 month ago

Error when running python3.10 terravision draw --source ~/infra/terraform/modules --workspace dev

.... Processing variables..

Processing resources.. random_string.unique_suffix module.ecr_settings.aws_ecr_registry_policy.cross_account_ecr_policy module.user_docs.aws_s3_bucket.docs_bucket module.user_docs.aws_s3_bucket_website_configuration.user_docs_config module.user_docs.aws_s3_bucket_public_access_block.this module.user_docs.aws_s3_bucket_ownership_controls.this module.user_docs.aws_s3_bucket_acl.this module.user_docs.aws_s3_bucket_versioning.this module.user_docs.aws_s3_bucket_policy.docs_bucket_policy module.user_docs.aws_acm_certificate.user_docs_cert module.user_docs.aws_route53_record.user_docs_cert_validation module.user_docs.aws_acm_certificate_validation.user_docs_cert_validation module.user_docs.aws_cloudfront_distribution.docs_bucket_distribution module.user_docs.aws_route53_record.user_docs module.user_docs.aws_cloudfront_origin_access_identity.user_docs_origin_access_identity

Checking for additional links between 16 resources.. module.user_docs.aws_acm_certificate_validation.user_docs_cert_validation --> module.user_docs.aws_acm_certificate.user_docs_cert module.user_docs.aws_acm_certificate_validation.user_docs_cert_validation --> module.user_docs.aws_acm_certificate_validation.user_docs_cert_validation module.user_docs.aws_route53_record.user_docs --> module.user_docs.aws_acm_certificate_validation.user_docs_cert_validation module.user_docs.aws_cloudfront_distribution.docs_bucket_distribution --> module.user_docs.aws_s3_bucket.docs_bucket module.user_docs.aws_s3_bucket.docs_bucket --> module.user_docs.aws_cloudfront_distribution.docs_bucket_distribution module.user_docs.aws_cloudfront_distribution.docs_bucket_distribution --> module.user_docs.aws_acm_certificate.user_docs_cert module.user_docs.aws_route53_record.user_docs --> module.user_docs.aws_acm_certificate.user_docs_cert module.user_docs.aws_s3_bucket.docs_bucket --> random_string.unique_suffix module.user_docs.aws_s3_bucket_acl.this --> module.user_docs.aws_s3_bucket.docs_bucket Unhandled error: <class 'KeyError'>, 'aws_cloudfront_distribution.docs_bucket_distribution', <traceback object at 0x132975900>

gitjonez commented 5 days ago

Also have similar issue with KeyError aws_internet_gateway.igw Python 3.11.9

❯ terravision draw --source .

...
Preflight check..
  dot command detected: /opt/homebrew/bin/dot
  gvpr command detected: /opt/homebrew/bin/gvpr
  git command detected: /opt/homebrew/bin/git
  terraform command detected: /Users/redacted/bin/terraform

Checking Terraform Version...

Terraform v1.9.6
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 5.16"...
- Finding latest version of hashicorp/null...
- Installing hashicorp/aws v5.76.0...
- Installed hashicorp/aws v5.76.0 (signed by HashiCorp)
- Installing hashicorp/null v3.2.3...
- Installed hashicorp/null v3.2.3 (signed by HashiCorp)

Terraform has been successfully initialized!

...

Saved the plan to: /var/folders/4v/_ym010l52n-REDACTED-8w2c0000gn/T/tfplan.bin

To perform exactly these actions, run the following command to apply:
    terraform apply "/var/folders/4v/_ym010l52n-REDACTED-8w2c0000gn/T/tfplan.bin"

Decoding plan..

Analysing plan..

Converting TF Graph Connections..  (this may take a while)

Unprocessed terraform graph dictionary:

{
    "aws_instance.bastion": [
        "null_resource.provisioner"
    ],
    "aws_instance.private_host": [],
    "aws_internet_gateway.igw": [
        "aws_route.default"
    ],
    "aws_route.default": [],
    "aws_route_table.private": [
        "aws_route_table_association.private",
        "aws_vpc_endpoint.s3"
    ],
    "aws_route_table_association.private": [],
    "aws_security_group.allow_icmp": [
        "aws_instance.bastion",
        "aws_instance.private_host",
        "aws_vpc_security_group_egress_rule.icmp_all_egress",
        "aws_vpc_security_group_ingress_rule.icmp_ingress"
    ],
    "aws_security_group.allow_ssh": [
        "aws_instance.bastion",
        "aws_vpc_security_group_egress_rule.ssh_egress",
        "aws_vpc_security_group_ingress_rule.ssh_ingress"
    ],
    "aws_security_group.interface_ep": [
        "aws_vpc_endpoint.ec2",
        "aws_vpc_security_group_egress_rule.if_ep_out",
        "aws_vpc_security_group_ingress_rule.if_ep_in"
    ],
    "aws_security_group.private_ssh": [
        "aws_instance.private_host",
        "aws_vpc_security_group_egress_rule.pvt_egress",
        "aws_vpc_security_group_egress_rule.pvt_egress_pfxlst",
        "aws_vpc_security_group_ingress_rule.pvt_ingress"
    ],
    "aws_subnet.sub1": [
        "aws_instance.bastion"
    ],
    "aws_subnet.sub2": [
        "aws_instance.private_host",
        "aws_internet_gateway.igw",
        "aws_route_table_association.private",
        "aws_vpc_endpoint.ec2"
    ],
    "aws_vpc.vpc": [
        "aws_route_table.private",
        "aws_security_group.allow_icmp",
        "aws_security_group.allow_ssh",
        "aws_security_group.interface_ep",
        "aws_security_group.private_ssh",
        "aws_subnet.sub1",
        "aws_vpc_dhcp_options_association.dhcpassoc",
        "aws_vpc_ipv4_cidr_block_association.cidr2",
        "aws_subnet.sub1"
    ],
    "aws_vpc_dhcp_options.dns_resolver": [
        "aws_vpc_dhcp_options_association.dhcpassoc"
    ],
    "aws_vpc_dhcp_options_association.dhcpassoc": [],
    "aws_vpc_endpoint.ec2": [],
    "aws_vpc_endpoint.s3": [],
    "aws_vpc_ipv4_cidr_block_association.cidr2": [
        "aws_subnet.sub2"
    ],
    "aws_vpc_security_group_egress_rule.icmp_all_egress": [],
    "aws_vpc_security_group_egress_rule.if_ep_out": [],
    "aws_vpc_security_group_egress_rule.pvt_egress": [],
    "aws_vpc_security_group_egress_rule.pvt_egress_pfxlst": [],
    "aws_vpc_security_group_egress_rule.ssh_egress": [],
    "aws_vpc_security_group_ingress_rule.icmp_ingress": [],
    "aws_vpc_security_group_ingress_rule.if_ep_in": [],
    "aws_vpc_security_group_ingress_rule.pvt_ingress": [],
    "aws_vpc_security_group_ingress_rule.ssh_ingress": [],
    "null_resource.provisioner": []
}

Parsing Terraform Source Files..
  Added Source Location: .
  Parsing ./interface_endpoint.tf
  Parsing ./gateway_endpoint.tf
    Found 1 output stanza(s)
    Found 2 resource stanza(s)
    Found 1 data stanza(s)
  Parsing ./ec2_endpoint.tf
    Found 1 output stanza(s)
    Found 1 resource stanza(s)
  Parsing ./variables.tf
    Found 12 output stanza(s)
    Found 17 variable stanza(s)
  Parsing ./instances.tf
    Found 3 output stanza(s)
    Found 3 resource stanza(s)
    Found 1 data stanza(s)
  Parsing ./provider.tf
    Found 1 data stanza(s)
  Parsing ./vpc.tf
    Found 22 resource stanza(s)
    Found 1 data stanza(s)

Processing variables..

Processing resources..
   aws_vpc_security_group_egress_rule.pvt_egress_pfxlst
   aws_vpc_endpoint.s3
   aws_vpc_endpoint.ec2
   aws_instance.bastion
   aws_instance.private_host
   null_resource.provisioner
   aws_vpc.vpc
   aws_vpc_ipv4_cidr_block_association.cidr2
   aws_subnet.sub1
   aws_subnet.sub2
   aws_vpc_dhcp_options.dns_resolver
   aws_vpc_dhcp_options_association.dhcpassoc
   aws_route_table.private
   aws_route_table_association.private
   aws_internet_gateway.igw
   aws_route.default
   aws_security_group.allow_ssh
   aws_vpc_security_group_ingress_rule.ssh_ingress
   aws_vpc_security_group_egress_rule.ssh_egress
   aws_security_group.private_ssh
   aws_vpc_security_group_ingress_rule.pvt_ingress
   aws_vpc_security_group_egress_rule.pvt_egress
   aws_security_group.allow_icmp
   aws_vpc_security_group_ingress_rule.icmp_ingress
   aws_vpc_security_group_egress_rule.icmp_all_egress
   aws_security_group.interface_ep
   aws_vpc_security_group_ingress_rule.if_ep_in
   aws_vpc_security_group_egress_rule.if_ep_out

Checking for additional links between 28 resources..
   aws_vpc.vpc --> aws_internet_gateway.igw
   aws_route.default --> aws_vpc_ipv4_cidr_block_association.cidr2
   aws_vpc.vpc --> aws_subnet.sub2
   aws_vpc.vpc --> aws_vpc_endpoint.ec2
   aws_vpc.vpc --> aws_vpc_endpoint.s3
Unhandled error: <class 'KeyError'>, 'aws_internet_gateway.igw', <traceback object at 0x11530b300>

If yous need anything else or, if yous could point me at where/what in the terravision code I could look at, let me know. Not sure I'm up for cold start investigation. I could trade yous for getting to work with python3.12... it wasn't very happy with that =) Cheers.