CfnMountTargetProps.builder().withFileSystemId() causes exception
See original GitHub issue- I’m submitting a …
- 🪲 bug report
Working with EFS. In versions prior to 0.35.0 the class CfnFileSystem
class had a getter operation getFileSystemId()
The fileSystemId is needed to create a mount point similar to below:
CfnMountTargetProps mtProps = CfnMountTargetProps.builder()
.withFileSystemId(efs.getFileSystemId())
.withSecurityGroups(…))
.withSubnetId(subnet.getSubnetId())
.build();
new CfnMountTarget(this, someName, mtProps)
In versions from 0.35.0 including CDK 1.0.0, the CfnFileSystem.getFileSystemId()
operation has been removed.
When attempting to resolve the id with CfnFileSystem.getRef() this produces the following exception.
software.amazon.jsii.JsiiException: Cannot use tokens in construct ID: CLUSTER-EFS-${Token[TOKEN.17]}
Attempting this using the recommended Lazy
approach:
CfnMountTargetProps mtProps = CfnMountTargetProps.builder()
.withFileSystemId(Lazy.stringValue(iResolveContext -> efs.getRef()))
.withSecurityGroups(…))
.withSubnetId(subnet.getSubnetId())
.build();
new CfnMountTarget(this, someName, mtProps)
also produces the same exception.
It appears that this may be a bug, since the file system id is a string as far as I am aware probably should not be returned as a token value.
It seems that the solution is to re-introduce the CfnFileSystem.getFileSystemId()
getter.
- CDK CLI Version: 1.0.0
- Module Version: 1.0.0
- OS: OSX Mojave
- Language: Java 8
- Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)
Exception in thread "main" software.amazon.jsii.JsiiException: Cannot use tokens in construct ID: CLUSTER-EFS-${Token[TOKEN.17]}
Error: Cannot use tokens in construct ID: CLUSTER-EFS-${Token[TOKEN.17]}
at new ConstructNode (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-kernel-AClHaD/node_modules/@aws-cdk/core/lib/construct.js:40:19)
at new Construct (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-kernel-AClHaD/node_modules/@aws-cdk/core/lib/construct.js:453:21)
at new CfnElement (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-kernel-AClHaD/node_modules/@aws-cdk/core/lib/cfn-element.js:32:9)
at new CfnRefElement (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-kernel-AClHaD/node_modules/@aws-cdk/core/lib/cfn-element.js:117:1)
at new CfnResource (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-kernel-AClHaD/node_modules/@aws-cdk/core/lib/cfn-resource.js:21:9)
at new CfnMountTarget (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-kernel-AClHaD/node_modules/@aws-cdk/aws-efs/lib/efs.generated.js:224:9)
at obj._wrapSandboxCode (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6661:49)
at Kernel._wrapSandboxCode (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:7129:19)
at Kernel._create (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6661:26)
at Kernel.create (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6414:21)
at KernelHost.processRequest (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6186:28)
at KernelHost.run (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6132:14)
at processRequest (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6132:45)
at KernelHost.processRequest (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6228:16)
at KernelHost.run (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6132:14)
at processRequest (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6132:45)
at KernelHost.processRequest (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6228:16)
at KernelHost.run (/private/var/folders/jw/047rd6j54_b_dcy4v2xzkh3h0000gn/T/jsii-java-runtime8734582455620817339/jsii-runtime.js:6132:14)
at software.amazon.jsii.JsiiRuntime.processErrorResponse(JsiiRuntime.java:112)
at software.amazon.jsii.JsiiRuntime.requestResponse(JsiiRuntime.java:84)
at software.amazon.jsii.JsiiClient.createObject(JsiiClient.java:90)
at software.amazon.jsii.JsiiEngine.createNewObject(JsiiEngine.java:458)
at software.amazon.awscdk.services.efs.CfnMountTarget.<init>(CfnMountTarget.java:28)
at za.co.absa.platform.aws.cdk.construct.Wso2Stack.provisionEfs(Wso2Stack.java:162)
at za.co.absa.platform.aws.cdk.construct.Wso2Stack.<init>(Wso2Stack.java:57)
at za.co.absa.platform.aws.cdk.BuilderApp.defineStack(BuilderApp.java:69)
at za.co.absa.platform.aws.cdk.BuilderApp.main(BuilderApp.java:62)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Can you please clarify how one can get the file_system_id using getRef now? I use the python cdk
getRef() is working fine.
The problem was I was using the expression “subnet.getAvailabilityZone()” as part of the “id” parameter being passed to the CfnMountTarget constructor. This expression resolving as a token at the time of construction and is not allowed in that context.