mirror of
https://github.com/patrickchugh/terravision.git
synced 2026-05-09 16:35:30 +02:00
[GH-ISSUE #134] Unhandled error: <class 'KeyError'>, 'aws_cloudfront_distribution.docs_bucket_distribution' #76
Labels
No labels
bug
enhancement
enhancement
good first issue
good first issue
good first issue
pipeline
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/terravision#76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @felipeyoneharatw on GitHub (Oct 3, 2024).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/134
Originally assigned to: @patrickchugh on GitHub.
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 on GitHub (Nov 21, 2024):
Also have similar issue with KeyError
aws_internet_gateway.igwPython 3.11.9If yous need anything else or, if yous could point me at where/what in the
terravisioncode I could look at, let me know. Not sure I'm up for cold start investigation. I could trade yous for getting to work withpython3.12... it wasn't very happy with that =) Cheers.@hangrybear666 commented on GitHub (Feb 10, 2026):
Have several KeyErrors preventing any AWS image generation at all. Each time I add a count = 1 to my resources to fix the KeyError, a new one appears, I will likely have to abort using terravision until this is fixed, the code shouldn't expect all these resources to have count defined, in fact most of the times it is not.
KeyError ALB
KeyError ElastiCache
KeyError aws_ses_domain_dkim
KeyError Cloudfront
KeyError S3 Bucket
@hangrybear666 commented on GitHub (Feb 10, 2026):
@patrickchugh I have analyzed the source code and think one of the issues might be that this line has an unsafe access to a node that might not be defined. https://github.com/patrickchugh/terravision/blob/main/modules/graphmaker.py#L357
And these lines directly access the count variable without checking if it is even defined
https://github.com/patrickchugh/terravision/blob/main/modules/resource_handlers_aws.py#L672
@patrickchugh commented on GitHub (Feb 10, 2026):
Thanks @hangrybear666 can you share a sample repo or source code zip so I can try to reproduce this error and fix it ? If not you can also run terravision with --debug and send me the tfdata.json if you prefer.
@hangrybear666 commented on GitHub (Feb 10, 2026):
It's an enterprise repository with 375 aws resources and lots of sensitive data I'm not sure how to share this responsibly while staying in line with my security team, also there are several layers of higher level infrastructure repos above mine from the operations team that deploy resources outside of my control, I'm currently unsure how to share a reproducible snippet wonder how others here have done it to help you out
@patrickchugh commented on GitHub (Feb 11, 2026):
Ok let me see if I can create a an updated version more verbose debugging output that can help me pinpoint the problem.
@patrickchugh commented on GitHub (Feb 15, 2026):
@gitjonez @hangrybear666 @felipeyoneharatw @gliptak I replaced ~80 unsafe del/.remove() calls across 7 files with 3 new safe helpers in helpers.py: delete_node(), rename_node(), and safe_remove_connection(). These prevent the KeyError and ValueError crashes reported in issue #134, where pipeline stages would delete/rename nodes but leave stale references that later stages would crash on trying to access or remove. Please try out latest version and let me know.
@hangrybear666 commented on GitHub (Feb 16, 2026):
It worked for the first time and generated a diagram for our entire prod environment!
Thank you!!