question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
w601sxscommented, Jul 16, 2019

Can you please clarify how one can get the file_system_id using getRef now? I use the python cdk

0reactions
nigel-bakkercommented, Jul 31, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RetryableException.Builder (AWS SDK for Java - 2.18.6)
build(). Creates a new SdkException with the specified properties. RetryableException.Builder. cause(Throwable cause). Specifies the exception that caused ...
Read more >
UriBuilderException (Java(TM) EE 7 Specification APIs)
UriBuilderException (Throwable cause). Constructs a new exception with the specified cause and a detail message of ( cause==null ? null : cause.toString() ) ......
Read more >
java - Builder pattern for methods with exception handling
If I use a builder pattern, then do() will have to throw this exception and therefore all clients will have to handle it....
Read more >
SmartServiceException.Builder (Appian API)
SmartServiceException.Builder · addCauseToAlertMessageArgs(). Specifies that the message of the cause exception should be added to the list of arguments passed ...
Read more >
ModelBuildingException (Maven Model Builder 3.0.4 API)
Gets the problems that caused this exception. ModelBuildingResult · getResult() Gets the interim result of the model building up to the point where...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found