You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. Perhaps I am misunderstanding the purpose of the allow_downloads flag- my expectation is that setting this to False would prevent tfparse from downloading any external modules. This does not appear to be the case! A demonstration:
~/Work/misc/tfparse-wtf/test $ pyenv activate tfparse-test
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(tfparse-test) [2:43PM][zzzzz@xx-m-zzzzz]~/Work/misc/tfparse-wtf/test $ python3 --version
Python 3.10.11
(tfparse-test) [2:43PM][zzzzz@xx-m-zzzzz]~/Work/misc/tfparse-wtf/test $ pip3 install tfparse
Collecting tfparse
Using cached tfparse-0.6.2-cp310-cp310-macosx_10_9_x86_64.whl (8.8 MB)
Collecting cffi>=1.0.0
Using cached cffi-1.16.0-cp310-cp310-macosx_10_9_x86_64.whl (182 kB)
Collecting pycparser
Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Installing collected packages: pycparser, cffi, tfparse
Successfully installed cffi-1.16.0 pycparser-2.21 tfparse-0.6.2
[notice] A new release of pip is available: 23.0.1 -> 23.3.1
[notice] To update, run: python3.10 -m pip install --upgrade pip
(tfparse-test) ~/Work/misc/tfparse-wtf/test $ ls
parse.py* test.tf
(tfparse-test) ~/Work/misc/tfparse-wtf/test $ cat parse.py
#!/usr/bin/env python3
from tfparse import load_from_path
parsed = load_from_path('.', allow_downloads=False, debug=True)
(tfparse-test) ~/Work/misc/tfparse-wtf/test $ cat test.tf
locals {
vpc_id = "<vpc_id>"
subnet_id = "<subnet_id>"
tags = {
service = "myservice"
application = "myapplication"
oncall = "ME"
}
}
module "my_instance" {
source = "[email protected]:iac/terraform-aws-ec2.git//instance"
hostname = "myhostname"
service_key = "myservice"
security_group_ids = [aws_security_group.my_sg.id]
subnet_id = "mysubnet"
tags = local.tags
}
resource "aws_security_group" "my_sg" {
name = "myservice-sg"
vpc_id = local.vpc_id
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["10.0.0.0/8"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = local.tags
}
(tfparse-test) ~/Work/misc/tfparse-wtf/test $ ./parse.py
51:50.555307000 terraform.parser.<root> Setting project/module root to '.'
51:50.555803000 terraform.parser.<root> Parsing FS from '.'
51:50.556035000 terraform.parser.<root> Parsing 'test.tf'...
51:50.556599000 terraform.parser.<root> Added file test.tf.
51:50.556631000 terraform.parser.<root> Evaluating module...
51:50.556844000 terraform.parser.<root> Read 3 block(s) and 0 ignore(s) for module 'root' (1 file[s])...
51:50.556870000 terraform.parser.<root> Added 0 variables from tfvars.
51:50.556892000 terraform.parser.<root> Error loading module metadata: open .terraform/modules/modules.json: no such file or directory.
51:50.556913000 terraform.parser.<root> Working directory for module evaluation is '/Users/zzzzz/Work/misc/tfparse-wtf/test'
51:50.556973000 terraform.parser.<root>.evaluator Filesystem key is '4a38c2413d8b6e6df90c8e8f87e44e0e96fabb95e3ee33d3e6d7253583c5e1dd'
51:50.556982000 terraform.parser.<root>.evaluator Starting module evaluation...
51:50.557148000 terraform.parser.<root>.evaluator Starting submodule evaluation...
51:50.557159000 terraform.parser.<root>.evaluator locating non-initialised module '[email protected]:iac/terraform-aws-ec2.git//instance'...
51:50.557167000 terraform.parser.<root>.evaluator.resolver Resolving module 'module.my_instance' with source: '[email protected]:iac/terraform-aws-ec2.git//instance'...
51:50.557397000 terraform.parser.<root>.evaluator.resolver Trying to resolve: 6930244acd24452ca855ba1695a1b415
51:50.557463000 terraform.parser.<root>.evaluator.resolver Module 'module.my_instance' resolving via cache...
51:50.557612000 terraform.parser.<root>.evaluator.resolver Module path is .
51:50.557624000 terraform.parser.<root>.evaluator Module 'module.my_instance' resolved to path '.' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.557637000 terraform.parser.<my_instance> Parsing FS from '.'
51:50.557833000 terraform.parser.<my_instance> Parsing 'data.tf'...
51:50.558244000 terraform.parser.<my_instance> Added file data.tf.
51:50.558269000 terraform.parser.<my_instance> Parsing 'main.tf'...
51:50.559748000 terraform.parser.<my_instance> Added file main.tf.
51:50.559780000 terraform.parser.<my_instance> Parsing 'outputs.tf'...
51:50.560012000 terraform.parser.<my_instance> Added file outputs.tf.
51:50.560035000 terraform.parser.<my_instance> Parsing 'variables.tf'...
51:50.561406000 terraform.parser.<my_instance> Added file variables.tf.
51:50.561436000 terraform.parser.<root>.evaluator Loaded module 'my_instance' from '.'.
51:50.561441000 terraform.parser.<my_instance> Evaluating module...
51:50.565829000 terraform.parser.<my_instance> Read 58 block(s) and 0 ignore(s) for module 'my_instance' (4 file[s])...
51:50.565871000 terraform.parser.<my_instance> Added 7 input variables from module definition.
51:50.565973000 terraform.parser.<my_instance> Error loading module metadata: open /var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415/.terraform/modules/modules.json: no such file or directory.
51:50.566000000 terraform.parser.<my_instance> Working directory for module evaluation is '/Users/zzzzz/Work/misc/tfparse-wtf/test'
51:50.566050000 terraform.parser.<my_instance>.evaluator Filesystem key is 'fdf7f0dbccf648dfcfdc8b6e11736de2f3cd032ea9cf129a81ff98cfb9d26896'
51:50.566056000 terraform.parser.<my_instance>.evaluator Starting module evaluation...
51:50.568457000 terraform.parser.<my_instance>.evaluator Expanded block 'aws_ebs_volume.add_volumes' into 0 clones via 'count' attribute.
51:50.568488000 terraform.parser.<my_instance>.evaluator Expanded block 'aws_network_interface.localnic' into 0 clones via 'count' attribute.
51:50.568507000 terraform.parser.<my_instance>.evaluator Expanded block 'aws_volume_attachment.volume_attachment' into 0 clones via 'count' attribute.
51:50.568520000 terraform.parser.<my_instance>.evaluator Expanded block 'module.fqdn' into 0 clones via 'count' attribute.
51:50.568669000 terraform.parser.<my_instance>.evaluator Expanded block 'module.hostname' into 1 clones via 'count' attribute.
51:50.568766000 terraform.parser.<my_instance>.evaluator Expanded block 'module.idm_enroll' into 1 clones via 'count' attribute.
51:50.568793000 terraform.parser.<my_instance>.evaluator Expanded block 'module.outpost' into 0 clones via 'count' attribute.
51:50.568924000 terraform.parser.<my_instance>.evaluator Expanded block 'module.the_instance_rr' into 1 clones via 'count' attribute.
51:50.569040000 terraform.parser.<my_instance>.evaluator Starting submodule evaluation...
51:50.569057000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/asa'...
51:50.569067000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.asa' with source: '../_modules/asa'...
51:50.569316000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: b9e5cc718cbbafa1ced42bb35c2187e8
51:50.569392000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.asa' resolved locally to ../_modules/asa
51:50.569400000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/asa
51:50.569408000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.asa' resolved to path '../_modules/asa' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.569422000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/asa: invalid argument'. Maybe try 'terraform init'?
51:50.569430000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/dns'...
51:50.569435000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.dns' with source: '../_modules/dns'...
51:50.569655000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: 8e5be0f5c65f05b59591ccc200a431ff
51:50.569773000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.dns' resolved locally to ../_modules/dns
51:50.569784000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/dns
51:50.569791000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.dns' resolved to path '../_modules/dns' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.569800000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/dns: invalid argument'. Maybe try 'terraform init'?
51:50.569807000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/finalize'...
51:50.569812000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.finalize' with source: '../_modules/finalize'...
51:50.570054000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: 53b6d0992a103f84b742bcb9ce1ffb15
51:50.570133000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.finalize' resolved locally to ../_modules/finalize
51:50.570141000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/finalize
51:50.570148000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.finalize' resolved to path '../_modules/finalize' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.570156000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/finalize: invalid argument'. Maybe try 'terraform init'?
51:50.570163000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/initialize'...
51:50.570169000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.initialize' with source: '../_modules/initialize'...
51:50.570315000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: 8231b14d2e0327179ad85efbf82a26a3
51:50.570374000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.initialize' resolved locally to ../_modules/initialize
51:50.570381000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/initialize
51:50.570387000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.initialize' resolved to path '../_modules/initialize' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.570396000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/initialize: invalid argument'. Maybe try 'terraform init'?
51:50.570402000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/nessusagent'...
51:50.570407000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.nessusagent' with source: '../_modules/nessusagent'...
51:50.570604000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: 95cfc8137c2f8a2c99ff43683d3dd323
51:50.570684000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.nessusagent' resolved locally to ../_modules/nessusagent
51:50.570691000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/nessusagent
51:50.570698000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.nessusagent' resolved to path '../_modules/nessusagent' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.570706000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/nessusagent: invalid argument'. Maybe try 'terraform init'?
51:50.570721000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/hostname'...
51:50.570727000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.hostname[0]' with source: '../_modules/hostname'...
51:50.570933000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: 477caa982fb73ac8995bc2b848b47375
51:50.570992000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.hostname[0]' resolved locally to ../_modules/hostname
51:50.571000000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/hostname
51:50.571008000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.hostname[0]' resolved to path '../_modules/hostname' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.571015000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/hostname: invalid argument'. Maybe try 'terraform init'?
51:50.571022000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/idm-enroll'...
51:50.571027000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.idm_enroll[0]' with source: '../_modules/idm-enroll'...
51:50.571154000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: feb2fb368a76cc3973acce945be93719
51:50.571202000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.idm_enroll[0]' resolved locally to ../_modules/idm-enroll
51:50.571208000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/idm-enroll
51:50.571215000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.idm_enroll[0]' resolved to path '../_modules/idm-enroll' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.571220000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/idm-enroll: invalid argument'. Maybe try 'terraform init'?
51:50.571227000 terraform.parser.<my_instance>.evaluator locating non-initialised module '../_modules/rr'...
51:50.571232000 terraform.parser.<my_instance>.evaluator.resolver Resolving module 'module.my_instance.module.the_instance_rr[0]' with source: '../_modules/rr'...
51:50.571363000 terraform.parser.<my_instance>.evaluator.resolver Trying to resolve: 8d0386dccb4799df85b869f6e012cd0d
51:50.571409000 terraform.parser.<my_instance>.evaluator.resolver Module 'module.my_instance.module.the_instance_rr[0]' resolved locally to ../_modules/rr
51:50.571415000 terraform.parser.<my_instance>.evaluator.resolver Module path is ../_modules/rr
51:50.571421000 terraform.parser.<my_instance>.evaluator Module 'module.my_instance.module.the_instance_rr[0]' resolved to path '../_modules/rr' in filesystem '/var/folders/3t/btv872q92n3c69blx6f70q8h0000gp/T/.aqua/cache/6930244acd24452ca855ba1695a1b415' with prefix '[email protected]:iac/terraform-aws-ec2.git/instance'
51:50.571426000 terraform.parser.<my_instance>.evaluator Failed to load module 'stat ../_modules/rr: invalid argument'. Maybe try 'terraform init'?
51:50.571429000 terraform.parser.<my_instance>.evaluator Finished processing 0 submodule(s).
51:50.571432000 terraform.parser.<my_instance>.evaluator Starting post-submodule evaluation...
51:50.572522000 terraform.parser.<my_instance>.evaluator Module evaluation complete.
51:50.572540000 terraform.parser.<my_instance> Finished parsing module 'my_instance'.
51:50.572547000 terraform.parser.<my_instance>.evaluator Added module output fqdn=cty.NilVal.
51:50.572600000 terraform.parser.<my_instance>.evaluator Added module output instance=cty.ObjectVal(map[string]cty.Value{"ami":cty.NilVal, "arn":cty.StringVal("eac6e51a-69f4-4449-8282-7cae1fd39ee1"), "associate_public_ip_address":cty.False, "availability_zone":cty.NilVal, "iam_instance_profile":cty.NilVal, "id":cty.StringVal("eac6e51a-69f4-4449-8282-7cae1fd39ee1"), "instance_type":cty.StringVal("t3.small"), "key_name":cty.NilVal, "subnet_id":cty.NilVal, "tags":cty.ObjectVal(map[string]cty.Value{"Name":cty.NilVal, "ami":cty.StringVal("mq_base_amzn2_x86_64"), "application":cty.StringVal("myapplication"), "oncall":cty.StringVal("ME"), "service":cty.StringVal("myservice")}), "user_data":cty.NilVal, "vpc_security_group_ids":cty.TupleVal([]cty.Value{cty.StringVal("c077ad44-d95d-424f-9dad-5bc47959e7be")})}).
51:50.572625000 terraform.parser.<my_instance>.evaluator Added module output instance_profile=cty.ObjectVal(map[string]cty.Value{"arn":cty.StringVal("ce6e1755-fd5f-45f8-9ce4-cf9d1237cf60"), "id":cty.StringVal("ce6e1755-fd5f-45f8-9ce4-cf9d1237cf60"), "role":cty.NilVal, "tags":cty.ObjectVal(map[string]cty.Value{"application":cty.StringVal("myapplication"), "oncall":cty.StringVal("ME"), "service":cty.StringVal("myservice")})}).
51:50.572643000 terraform.parser.<my_instance>.evaluator Added module output private_dns=cty.NilVal.
51:50.572648000 terraform.parser.<my_instance>.evaluator Added module output private_ip=cty.NilVal.
51:50.572658000 terraform.parser.<my_instance>.evaluator Added module output route53_record=cty.NilVal.
51:50.572672000 terraform.parser.<root>.evaluator Finished processing 1 submodule(s).
51:50.572676000 terraform.parser.<root>.evaluator Starting post-submodule evaluation...
51:50.572827000 terraform.parser.<root>.evaluator Module evaluation complete.
51:50.572833000 terraform.parser.<root> Finished parsing module 'root'.
(tfparse-test) ~/Work/misc/tfparse-wtf/test $
The text was updated successfully, but these errors were encountered:
thugdoubt
added a commit
to thugdoubt/tfparse
that referenced
this issue
Nov 16, 2023
Hello. Perhaps I am misunderstanding the purpose of the
allow_downloads
flag- my expectation is that setting this toFalse
would prevent tfparse from downloading any external modules. This does not appear to be the case! A demonstration:The text was updated successfully, but these errors were encountered: