Skip to content

(efs): fileSystem for lambda cannot be referenced from access point ARN #18113

@ttais2017

Description

@ttais2017

What is the problem?

AccessPoint.fromAccessPointId and AccessPoint.fromAccessPointAttributes do not allow to 'load' the access point.

Using one of those methods for loading the access point, the same exception is thrown: fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead

Reproduction Steps

Java Code

    String accessPointId = Fn.importValue(parent + Constants.__EV_ACCESS_POINT_ARN);
    IAccessPoint accessPoint = AccessPoint.fromAccessPointId(this, "ap4lambda", accessPointId);
    fs = software.amazon.awscdk.services.lambda.FileSystem.fromEfsAccessPoint(accessPoint, "/mnt/efs");

Exception

Caused by: software.amazon.jsii.JsiiException: fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead   
Error: fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead                                           
    at ImportedAccessPoint.get fileSystem [as fileSystem] (C:\TEMP\jsii-kernel-agO7DV\node_modules\@aws-cdk\aws-efs\lib\access-point.js:99:19)             
    at Function.fromEfsAccessPoint (C:\TEMP\jsii-kernel-agO7DV\node_modules\@aws-cdk\aws-lambda\lib\filesystem.js:34:29)                                   
    at C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:8269:114                                                                                 
    at Kernel._wrapSandboxCode (C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:8860:24)                                                        
    at C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:8269:87                                                                                  
    at Kernel._ensureSync (C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:8841:28)                                                             
    at Kernel.sinvoke (C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:8269:34)                                                                 
    at KernelHost.processRequest (C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:9757:36)                                                      
    at KernelHost.run (C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:9720:22)                                                                 
    at Immediate._onImmediate (C:\TEMP\jsii-java-runtime710286648045078614\lib\program.js:9721:46)                                                         
    at software.amazon.jsii.JsiiRuntime.processErrorResponse (JsiiRuntime.java:124)                                                                        
    at software.amazon.jsii.JsiiRuntime.requestResponse (JsiiRuntime.java:95)                                                                              
    at software.amazon.jsii.JsiiClient.callStaticMethod (JsiiClient.java:168)                                                                              
    at software.amazon.jsii.JsiiObject.jsiiStaticCall (JsiiObject.java:187)                                                                                
    at software.amazon.jsii.JsiiObject.jsiiStaticCall (JsiiObject.java:166)                                                                                
    at software.amazon.awscdk.services.lambda.FileSystem.fromEfsAccessPoint (FileSystem.java:71)                                                           
    at de.materna.aws.cdk.lamp.ResourcesNestedStack.importEfsAccessPoint (ResourcesNestedStack.java:83)                                                    

Following the suggestion (use fromAccessPointAttributes instead):

    accessPointArn = Fn.importValue(parent + Constants.__EV_ACCESS_POINT_ARN);
    IAccessPoint accessPoint = AccessPoint.fromAccessPointAttributes(this, "ap4lambda",
        AccessPointAttributes.builder()
            .accessPointArn(accessPointArn)
            .build());
    fs = software.amazon.awscdk.services.lambda.FileSystem.fromEfsAccessPoint(accessPoint, "/mnt/efs");

The same exception (by using fromAccessPointId):

Caused by: software.amazon.jsii.JsiiException: fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead      
Error: fileSystem is not available when 'fromAccessPointId()' is used. Use 'fromAccessPointAttributes()' instead                                              
    at ImportedAccessPoint.get fileSystem [as fileSystem] (C:\TEMP\jsii-kernel-gE2MK3\node_modules\@aws-cdk\aws-efs\lib\access-point.js:99:19)                
    at Function.fromEfsAccessPoint (C:\TEMP\jsii-kernel-gE2MK3\node_modules\@aws-cdk\aws-lambda\lib\filesystem.js:34:29)                                      
    at C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:8269:114                                                                                  
    at Kernel._wrapSandboxCode (C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:8860:24)                                                         
    at C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:8269:87                                                                                   
    at Kernel._ensureSync (C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:8841:28)                                                              
    at Kernel.sinvoke (C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:8269:34)                                                                  
    at KernelHost.processRequest (C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:9757:36)                                                       
    at KernelHost.run (C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:9720:22)                                                                  
    at Immediate._onImmediate (C:\TEMP\jsii-java-runtime13586202064559895875\lib\program.js:9721:46)                                                          
    at software.amazon.jsii.JsiiRuntime.processErrorResponse (JsiiRuntime.java:124)                                                                           
    at software.amazon.jsii.JsiiRuntime.requestResponse (JsiiRuntime.java:95)                                                                                 
    at software.amazon.jsii.JsiiClient.callStaticMethod (JsiiClient.java:168)                                                                                 
    at software.amazon.jsii.JsiiObject.jsiiStaticCall (JsiiObject.java:187)                                                                                   
    at software.amazon.jsii.JsiiObject.jsiiStaticCall (JsiiObject.java:166)                                                                                   
    at software.amazon.awscdk.services.lambda.FileSystem.fromEfsAccessPoint (FileSystem.java:71)                                                              
    at de.materna.aws.cdk.lamp.ResourcesNestedStack.importEfsAccessPoint (ResourcesNestedStack.java:87)                                                       

What did you expect to happen?

I would expect to be able to load the access point using its ARN.

What actually happened?

an exception will be thrown. :(

CDK CLI Version

cdk 2.2.0

Framework Version

1.135.0

Node.js Version

N/A

OS

Windows

Language

Java

Language Version

Java 11

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-efsRelated to Amazon Elastic File SystemdocumentationThis is a problem with documentation.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions