Structuring code, impact on .yml

I have structured my code in the following directories:

|-my-project 
     |- folder
            |-function1.js
            |-function2.js
            |-function3.js
     |-serverless.yml

All functions are structured in their own files, inside a folder. In the same location as the folder, I have a serverless.yml file, which describes those functions.

When I deploy them via the Serverless command, it uploads everything nicely and it creates a Lambda function in AWS for each declared function in my serverless.yml. However, I can’t access the code, as I get the following message in the AWS dashboard:

This function contains external libraries. Uploading a new file will override these libraries.

Is there a way of putting these functions in their own files, declaring them in the serverless.yml file, upload them and still being able to see the actual code in the AWS console? I’ve already tried multiple variations, but none of them worked:

  • folder.function1.functionname
  • functionname

None of these options seems to work.

This should work just fine. Your “problem” is that you want to see your lambda’s code in the AWS console. This is a limitation of lambda: as soon as you upload a zip instead of a single block of javascript code, you won’t be able to see the lambda’s code within the AWS console.

The real question is, why do you want to see your code in the AWS console? I believe you should stay away from the AWS console as much as possible, and just use the serverless framework and its functions within your code editor.

Can you confirm that the functions actually do work by making a HTTP request to them?