node.jsamazon-web-servicesaws-lambdasam

How can i add a file to my AWS SAM lambda function runtime?


While working with aws i need to load a WSDL file in order to setup a soap service. The problem I now encounter however is that i don't know how i can possibly add a file to the docker container running my lambda function so that i can just read the file inside my lambda like in the code snippet below.

    const files = readdirSync(__dirname + pathToWsdl);
    files.forEach(file => {
        log.info(file);
    });

any suggestions on how i can do this are greatly appreciated!


Solution

  • Here are a few options:

    1. If the files are static and small, you can bundle them in the Lambda package.
    2. If the files are static or change infrequently then you can store them in S3 and pull from there on Lambda cold start.
    3. If the files need to be accessed and modified by multiple Lambda functions concurrently or if you have a large volume of data with low-latency access requirements, then use EFS.

    EFS is overkill for a small, static file. I would just package the file with the Lambda function.