I get an "jsii.errors.JSIIError: Expected Scalar, got {"$jsii.byref":"@aws-cdk/core.Reference@10024"}" Error when I pass a subnet id to my Mount Target. Here is the code:
mountTarget = efs.CfnMountTarget(self, "EfsMounttarget",
file_system_id=filesystem.get_att("FileSystemId"),
security_groups= [ sg_asg ],
subnet_id=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC).subnet_ids[0]
)
when I print out the select_subnets method I get the correct id as a string.
print(type(vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC).subnet_ids[0]))
print(vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC).subnet_ids[0])
Output:
<class 'str'>
subnet-9b1f3bd3
The parameter expects a string so I'm stuck at this point.
Here is the complete Error Message:
jsii.errors.JavaScriptError:
Error: Expected Scalar, got {"$jsii.byref":"@aws-cdk/core.Reference@10024"}
at Object.deserialize (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6630:23)
at Kernel._toSandbox (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8111:61)
at /home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6841:29
at mapValues (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7101:27)
at Object.deserialize (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6837:20)
at Kernel._toSandbox (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8111:61)
at /home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8164:33
at Array.map (<anonymous>)
at Kernel._boxUnboxParameters (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8164:19)
at Kernel._wrapSandboxCode (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:8205:19)
at Kernel._create (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7749:26)
at Kernel.create (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7503:21)
at KernelHost.processRequest (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7293:28)
at KernelHost.run (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7233:14)
at Immediate._onImmediate (/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7236:37)
at processImmediate (internal/timers.js:439:21)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "app.py", line 9, in <module>
HelloCdkStack(app, "HelloCdkStack2", env={'region': 'eu-west-1', 'account': '000000000000'})
File "/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_runtime.py", line 66, in __call__
inst = super().__call__(*args, **kwargs)
File "/home/username/dev/tests/hello-cdk/hello_cdk/hello_cdk_stack.py", line 92, in __init__
subnet_id=vpc.select_subnets(subnet_type=ec2.SubnetType.PUBLIC).subnet_ids[0]
File "/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_runtime.py", line 66, in __call__
inst = super().__call__(*args, **kwargs)
File "/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/aws_cdk/aws_efs/__init__.py", line 385, in __init__
jsii.create(CfnMountTarget, self, [scope, id, props])
File "/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 223, in create
interfaces=[iface.__jsii_type__ for iface in getattr(klass, "__jsii_ifaces__", [])],
File "/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 333, in create
return self._process.send(request, CreateResponse)
File "/home/username/dev/tests/hello-cdk/.env/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 318, in send
raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: Expected Scalar, got {"$jsii.byref":"@aws-cdk/core.Reference@10024"}
Subprocess exited with error 1
Thanks for any help and advice.
the problem wasn't the subnet_id but the file_system_id this code works:
mountTarget = efs.CfnMountTarget(self, "EfsMounttarget"+str(i),
file_system_id=filesystem.ref,
security_groups= [ sg_efs.security_group_id ],
subnet_id=vpc.select_subnets(subnet_type=ec2.SubnetType.PRIVATE).subnets[0].subnet_id
)
filesystem is a CfnFileSystem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.