"CDKTF get" crashed while getting CDKTF module from private registry in CDKTF application

Tried to get CDKTF module from cloud registry in cdktf application, put
“terraformModules”: [
{
“name”: “custmod”,
“source”: “app.terraform.io/organization/custmod/aws”,
“version”: “~> 0.0.1”
}
],
in cdktf.json

And on “cdktf get” got error:

TypeError: Cannot read properties of undefined (reading ‘hasOwnProperty’)
at hlt (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:31107)
at mlt (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:32069)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:30786
at async Pde (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:43:854)
at async OH (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:30439)
at async IH.generateTypeScript (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:60:6272)
at async IH.generate (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:60:6534)
at async BJ (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:397:1325)
at async /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:419:9458
⠏ downloading and generating modules and providers…
Cannot read properties of undefined (reading ‘hasOwnProperty’)

Authentication token is in place. Module was successfully used with HCL calls. “cdktf --version” - 0.10.2. Folder “imports” after error is empty, there is no “.terraform” folder before or after execution.

End of output with “TF_LOG=TRACE” (it’s trying to download into “.terraform” folder even codeMakerOutput=“imports”)

2022-05-05T12:07:28.910-0400 [TRACE] getmodules: fetching "https://archivist.terraform.io/v1/object/token
⠋ downloading and generating modules and providers…
2022-05-05T12:07:29.167-0400 [TRACE] ModuleInstaller: custmod “https://archivist.terraform.io/v1/object/tokenZkelk9?archive=tgz” was downloaded to .terraform/modules/custmod
2022-05-05T12:07:29.167-0400 [TRACE] ModuleInstaller: custmod should now be at .terraform/modules/custmod
2022-05-05T12:07:29.167-0400 [DEBUG] Module installer: custmod installed at .terraform/modules/custmod
2022-05-05T12:07:29.167-0400 [TRACE] modsdir: writing modules manifest to .terraform/modules/modules.json
2022-05-05T12:07:29.168-0400 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2022-05-05T12:07:29.168-0400 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2022-05-05T12:07:29.168-0400 [DEBUG] New state was assigned lineage “56c414c0-76f9-b40d-0c56-ca14f7d73f0a”
2022-05-05T12:07:29.168-0400 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2022-05-05T12:07:29.168-0400 [TRACE] Meta.Backend: instantiated backend of type
2022-05-05T12:07:29.168-0400 [DEBUG] checking for provisioner in “.”
2022-05-05T12:07:29.171-0400 [DEBUG] checking for provisioner in “/usr/bin”
2022-05-05T12:07:29.171-0400 [TRACE] Meta.Backend: backend does not support operations, so wrapping it in a local backend
2022-05-05T12:07:29.171-0400 [TRACE] backend/local: state manager for workspace “default” will:

  • read initial snapshot from terraform.tfstate
  • write new snapshots to terraform.tfstate
  • create any backup at terraform.tfstate.backup
    2022-05-05T12:07:29.171-0400 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
    2022-05-05T12:07:29.171-0400 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that’s okay
    2022-05-05T12:07:29.171-0400 [TRACE] statemgr.Filesystem: read nil snapshot
    2022-05-05T12:07:29.171-0400 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
    ⠙ downloading and generating modules and providers…
    2022-05-05T12:07:29.252-0400 [DEBUG] GET https://registry.terraform.io/v1/providers/hashicorp/aws/versions
    ⠹ downloading and generating modules and providers…
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
    2022-05-05T12:07:29.355-0400 [TRACE] getproviders.SearchLocalDirectory: failed to resolve symlinks for .terraform/providers: lstat .terraform/providers: no such file or directory
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.fillMetaCache: error while scanning directory .terraform/providers: cannot search .terraform/providers: lstat .terraform/providers: no such file or directory
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.fillMetaCache: scanning directory /home/userid/.terraform.d/plugin-cache
    2022-05-05T12:07:29.355-0400 [TRACE] getproviders.SearchLocalDirectory: found Terraform Registry v4.10.0 for linux_amd64 at /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.10.0/linux_amd64
    2022-05-05T12:07:29.355-0400 [TRACE] getproviders.SearchLocalDirectory: found Terraform Registry v4.11.0 for linux_amd64 at /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.11.0/linux_amd64
    2022-05-05T12:07:29.355-0400 [TRACE] getproviders.SearchLocalDirectory: found Terraform Registry v4.12.1 for linux_amd64 at /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.12.1/linux_amd64
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.fillMetaCache: including /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.10.0/linux_amd64 as a candidate package for Terraform Registry 4.10.0
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.fillMetaCache: including /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.11.0/linux_amd64 as a candidate package for Terraform Registry 4.11.0
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.fillMetaCache: including /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.12.1/linux_amd64 as a candidate package for Terraform Registry 4.12.1
    2022-05-05T12:07:29.355-0400 [TRACE] providercache.Dir.LinkFromOtherCache: linking Terraform Registry v4.12.1 from existing cache /home/userid/.terraform.d/plugin-cache/registry.terraform.io/hashicorp/aws/4.12.1/linux_amd64 to .terraform/providers/registry.terraform.io/hashicorp/aws/4.12.1/linux_amd64
    2022-05-05T12:07:29.356-0400 [TRACE] providercache.fillMetaCache: scanning directory .terraform/providers
    2022-05-05T12:07:29.356-0400 [TRACE] getproviders.SearchLocalDirectory: found Terraform Registry v4.12.1 for linux_amd64 at .terraform/providers/registry.terraform.io/hashicorp/aws/4.12.1/linux_amd64
    2022-05-05T12:07:29.356-0400 [TRACE] providercache.fillMetaCache: including .terraform/providers/registry.terraform.io/hashicorp/aws/4.12.1/linux_amd64 as a candidate package for registry.te
    TypeError: Cannot read properties of undefined (reading ‘hasOwnProperty’)
    at hlt (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:31107)
    at mlt (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:32069)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:30786
    at async Pde (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:43:854)
    at async OH (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:53:30439)
    at async IH.generateTypeScript (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:60:6272)
    at async IH.generate (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:60:6534)
    at async BJ (/usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:397:1325)
    at async /usr/local/lib/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:419:9458
    ⠙ downloading and generating modules and providers…
    Cannot read properties of undefined (reading ‘hasOwnProperty’)

Hey there, I’m trying to debug this, could you help me out by setting the environment variable CDKTF_LOG_LEVEL=all to also get the CDKTF logs?

Also could you share the variable section of the module? This was the only place I found hasOwnProperty in our code, I’m pretty sure that’s not it, but I’d like to confirm that.

(it’s trying to download into “.terraform” folder even codeMakerOutput=“imports”)

The codeMakerOutput refers to the generated provider bindings. To get these we need to download all providers and modules to harvest the provider / module schema and generate bindings from these schemas. This is why a .terraform folder is created (in some tmp dir).

Hi,
Output for “CDKTF_LOG_LEVEL=all” is attached
Variables for module
image.png

Thanks,
Marat

out.txt (4.02 KB)

I would say it has something with module definition: if try to use module json (attached) as local module getting the same error for “cdktf get”.
Interesting that HCL is using this module without hiccups.

(Attachment main.tf.json is missing)

Module source as txt file

main.tf.json.txt (749 Bytes)