hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.79k stars 442 forks source link

TLS: RuntimeError: Cannot read properties of undefined #3106

Open Ducky4023 opened 10 months ago

Ducky4023 commented 10 months ago

Expected Behavior

cdktf synth successful.

Actual Behavior

cdktf synth output:

[2023-08-23T20:41:11.761] [ERROR] default - jsii.errors.JavaScriptError: 
  TypeError: Cannot read properties of undefined (reading 'TlsProvider')
      at Kernel._Kernel_findSymbol (/tmp/tmpq5zjack7/lib/program.js:10304:28)
      at Kernel._Kernel_findCtor (/tmp/tmpq5zjack7/lib/program.js:10045:100)
      at Kernel._Kernel_create (/tmp/tmpq5zjack7/lib/program.js:10069:103)
      at Kernel.create (/tmp/tmpq5zjack7/lib/program.js:9742:93)
      at KernelHost.processRequest (/tmp/tmpq5zjack7/lib/program.js:11658:36)
      at KernelHost.run (/tmp/tmpq5zjack7/lib/program.js:11618:22)
      at Immediate._onImmediate (/tmp/tmpq5zjack7/lib/program.js:11619:46)
      at process.processImmediate (node:internal/timers:478:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/username/git/personal/cdktf-test/main.py", line 16, in <module>
    MyStack(app, "cdktf-test")
  File "/home/username/git/personal/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/home/username/git/personal/cdktf-test/main.py", line 12, in __init__
    TlsProvider(self, "blah")
  File "/home/username/git/personal/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_runtime.py", line 118, in __call__
    inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
  File "/home/username/git/personal/cdktf-test/imports/tls/provider/__init__.py", line 52, in __init__
    jsii.create(self.__class__, self, [scope, id, config])
  File "/home/username/git/personal/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_kernel/__init__.py", line 334, in create
    response = self.provider.create(
  File "/home/username/git/personal/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 365, in create
    return self._process.send(request, CreateResponse)
  File "/home/username/git/personal/cdktf-test/.venv/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 342, in send
    raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
ERROR: cdktf encountered an error while synthesizing

Steps to Reproduce

Create python project and add TLS provider

Sample code that chokes on cdktf synth

#!/usr/bin/env python
from cdktf import App, TerraformStack
from constructs import Construct

from imports.tls.provider import TlsProvider

class MyStack(TerraformStack):
    def __init__(self, scope: Construct, name: str):
        super().__init__(scope, name)

        TlsProvider(self, "tls")

app = App()
MyStack(app, "cdktf-test")

app.synth()

Versions

language: python cdktf-cli: 0.18.0 node: 20.5.1 cdktf: 0.18.0 constructs: 10.2.69 jsii: 1.87.0 terraform: 1.5.6 arch: x86_64 os: Linux Mint 21.2 (kernel 6.2.0-26-generic)

Providers

┌───────────────┬──────────────────┬───────┬────────────┬──────────────┬─────────────────┐ │ Provider Name │ Provider Version │ CDKTF │ Constraint │ Package Name │ Package Version │ ├───────────────┼──────────────────┼───────┼────────────┼──────────────┼─────────────────┤ │ tls │ 4.0.4 │ │ │ │ │ └───────────────┴──────────────────┴───────┴────────────┴──────────────┴─────────────────┘

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

This occurs with existing projects and as well as new ones.

References

No response

Help Wanted

Community Note

schlegel11 commented 1 month ago

Hello :smile: I can reproduce the same issue and this ticket is open for half a year. Is there any progress?

schlegel11 commented 1 month ago

Ok the workaround is to use the prebuild binding directly from PyPI https://github.com/cdktf/cdktf-provider-tls https://pypi.org/project/cdktf-cdktf-provider-tls/