skip to Main Content

I have a use case to add two EFS filesystems to lambda. But the File System config tab for AWS lambda allows me to add only one EFS file system.

Is there any way to accomplish this? If it is not possible, is there any alternate solution, like creating a logical symlink EFS that points to the other two existing EFS?

2

Answers


  1. Currently looks to be unsupported by the CDK: https://github.com/aws/aws-cdk/issues/14885.

    Although I have not tried to mount them to a Lambda, I know it’s fairly simple to mount multiples on EC2 instance, so should be possible. Make sure your policy contains at least these three actions:

    elasticfilesystem:ClientRootAccess
    elasticfilesystem:ClientMount
    elasticfilesystem:ClientWrite
    

    And try to mount:

    const aws = require('aws-sdk');
    const fs = require('fs');
    
    const efsClient = new aws.EFS();
    
    await efsClient.createMountTarget({
      FileSystemId: 'efs-1-id',
      SubnetId: 'efs-subnet-1-id',
      SecurityGroups: ['efs-sg-1-id'],
     }).promise();
    fs.mkdirSync('/efs1/mount/path');
    
    await efsClient.createMountTarget({
      FileSystemId: 'efs-2-id',
      SubnetId: 'efs-subnet-2-id',
      SecurityGroups: ['efs-sg-2-id'],
     }).promise();
    fs.mkdirSync('/efs2/mount/path');
    
    Login or Signup to reply.
  2. Use EFS access points. You can add a list of EFS access points to a Lambda where each access point is connected to a different EFS instance. AWS EFS Lambda confifuration

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search