JSII Error Trying to Reference Output Variable From Local Module

I just upgraded my existing codebase to CDKTF 0.9.0 and am now receiving a jsii error when running synth. There is a cdktf stack that calls out to a local “classic” terraform module. This module has an output variable that is then referenced by the cdktf stack. Runing cdktf commands now result in an error that appears to be around this.getString.

I have deleted the import directory and re-run the cdktf get command, but the error still occurs.

I’ve tried referencing the output variable both as it used to work and a new way as described in the new documentation here: Modules | Terraform by HashiCorp

New Documentation

  • TerraformOutput(self, “bucket_arn”, value=cloudtrail_log_bucket.bucket_arn_output)

As well as the way it used to work as:

  • cloudtrail_log_bucket.bucket_arn_output

This is the full error:

    jsii.errors.JavaScriptError: 
      TypeError: this.getString is not a function
          at S3Logging.get bucketArnOutput [as bucketArnOutput] (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/jsii-kernel-TSUPrz/node_modules/s3_logging/modules/s3_logging.js:38:21)
          at /private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:8219:150
          at Kernel._wrapSandboxCode (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:8860:24)
          at /private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:8219:118
          at Kernel._ensureSync (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:8841:28)
          at Kernel.get (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:8219:36)
          at KernelHost.processRequest (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:9757:36)
          at KernelHost.run (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:9720:22)
          at Immediate._onImmediate (/private/var/folders/yn/drhbs_8x33n7jdc87_mc5z600000gp/T/tmpmp5rdsi0/lib/program.js:9721:46)
          at processImmediate (node:internal/timers:464:21)

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

    Traceback (most recent call last):
      File "~/Documents/vscode/cdktf/organization_security/main.py", line 88, in <module>
        cloudtrail_stack = cloudtrail.CloudTrail(
      File "~/.local/share/virtualenvs/organization_security-_R6Ohsl1/lib/python3.9/site-packages/jsii/_runtime.py", line 86, in __call__
        inst = super().__call__(*args, **kwargs)
      File "~/Documents/vscode/cdktf/organization_security/cloudtrail.py", line 46, in __init__
        self.cloudtrail_s3_log_bucket = self.log_bucket(cloudtrail_log_bucket_name)
      File "~/Documents/vscode/cdktf/organization_security/cloudtrail.py", line 247, in log_bucket
        TerraformOutput(self, "bucket_arn", value=cloudtrail_log_bucket.bucket_arn_output)
      File "~/Documents/vscode/cdktf/organization_security/imports/s3_logging/__init__.py", line 51, in bucket_arn_output
        return typing.cast(builtins.str, jsii.get(self, "bucketArnOutput"))
      File "~/.local/share/virtualenvs/organization_security-_R6Ohsl1/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 143, in wrapped
        return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
      File "~/.local/share/virtualenvs/organization_security-_R6Ohsl1/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 316, in get
        response = self.provider.get(
      File "~/.local/share/virtualenvs/organization_security-_R6Ohsl1/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 347, in get
        return self._process.send(request, GetResponse)
      File "~/.local/share/virtualenvs/organization_security-_R6Ohsl1/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 326, in send
        raise JSIIError(resp.error) from JavaScriptError(resp.stack)
    jsii.errors.JSIIError: this.getString is not a function

Make sure that you have updated both the cdktf cli and the python cdktf package. getString was added in 0.9.0, so I suspect an older python package is being referenced.

Thank you - That was the issue.