(cloudfront): jsii.errors.JSIIError: Cannot read property 'uniqueId' of undefined
See original GitHub issuegetting this error when ‘cdk synth’ is run. I have pasted the entire code. It is the example code specified on reference docs.
Reproduction Steps
from aws_cdk import (
core,
aws_cloudfront as cfront,
aws_cloudfront_origins as cforigins,
aws_s3 as s3,
aws_certificatemanager as acm
)
from variables_list import (
Project,
Env
)
class CdnStack(core.Stack):
def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
super().__init__(scope, id, **kwargs)
# The code that defines your stack goes here
core.Tag.add(self,key='environment',value=Env)
core.Tag.add(self,key='project',value=Project)
my_bucket = s3.Bucket(self, "myBucket")
cfront.Distribution(self, "myDist",
default_behavior= cfront.BehaviorOptions(
origin=cforigins.S3Origin(my_bucket)
)
)
What did you expect to happen?
I am trying to create CloudFront distribution with s3 origin.
Error:
jsii.errors.JavaScriptError: TypeError: Cannot read property ‘uniqueId’ of undefined at Distribution.addOrigin (/tmp/jsii-kernel-i86csu/node_modules/@aws-cdk/aws-cloudfront/lib/distribution.js:108:43) at new Distribution (/tmp/jsii-kernel-i86csu/node_modules/@aws-cdk/aws-cloudfront/lib/distribution.js:35:31) at /home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7932:49 at Kernel._wrapSandboxCode (/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8420:19) at Kernel._create (/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7932:26) at Kernel.create (/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7676:21) at KernelHost.processRequest (/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7456:28) at KernelHost.run (/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7394:14) at Immediate._onImmediate (/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7397:37) at processImmediate (internal/timers.js:456:21)
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File “app.py”, line 246, in <module> cdn_stack = CdnStack( File “/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_runtime.py”, line 69, in call inst = super().call(*args, **kwargs) File “/home/administrator/repos/devops/automation/cdk_codes/stage/stage/cdn_stack.py”, line 24, in init cfront.Distribution(self, “myDist”, File “/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_runtime.py”, line 69, in call inst = super().call(*args, **kwargs) File “/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/aws_cdk/aws_cloudfront/init.py”, line 9216, in init jsii.create(Distribution, self, [scope, id, props]) File “/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_kernel/init.py”, line 246, in create response = self.provider.create( File “/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_kernel/providers/process.py”, line 336, in create return self._process.send(request, CreateResponse) File “/home/administrator/repos/devops/automation/cdk_codes/stage/.env/lib/python3.8/site-packages/jsii/_kernel/providers/process.py”, line 321, in send raise JSIIError(resp.error) from JavaScriptError(resp.stack) jsii.errors.JSIIError: Cannot read property ‘uniqueId’ of undefined
Environment
- CDK CLI Version : 1.79.0
- Node.js Version: v13.9.0
- OS : Linux
- Language (Version): Python3.8
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Ah, that’s the issue then; the
Distribution
construct was released in version 1.52.0. When you use the CDK, all versions must be in sync – you can’t use 1.52.0 (or newer) of CloudFront and 1.34.0 of Core.Your options are either to go through the work of upgrading your application to a newer version, or using the
CloudFrontWebDistribution
construct instead ofDistribution
.I’m going to resolve this, but feel free to reopen if you have any follow-up questions.
thank you very much @njlynch