0

I am trying to set up a lambda in pulumi-aws but my function code when deployed is wrapped in a folder with the same name as the generated lambda function name.

I would prefer not to have this as it's unnecessary, but more than that it means I can't work out what my handler should be as the folder name is generated?

(I realise I can probably use a reference to get this generated name, but I don't like the added complexity for no reason. I don't see a good reason for having this folder inside the lambda?)

E.g. my function code is 1 simple index.js file. with 1 named export of handler. I would expect my lambda handler to be index.handler.

(Note I am using TypeScript for my pulumi code but the Lambda is in JavaScript.)

I have tried a couple of options for the code property:

const addTimesheetEntryLambda = new aws.lambda.Function("add-timesheet-entry", {
    code: new pulumi.asset.AssetArchive({
        "index.js": new pulumi.asset.FileAsset('./lambdas/add-timesheet-entry/index.js'),
    }),

In this example the zip file was simply an index.js with no folder information in the zip.

const addTimesheetEntryLambda = new aws.lambda.Function("add-timesheet-entry", {
    code: new pulumi.asset.FileArchive("lambdatest.zip"),
Nick Meldrum
  • 1,141
  • 1
  • 10
  • 27

1 Answers1

3

AWS Lambda code is always in a "folder" named after the function name. Here is a Lambda that I created in the web console:

AWS Lambda in AWS Console

It doesn't affect the naming of the handler though. index.handler is just fine.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • You are absolutely right, can't believe I never noticed that before. Thanks for pointing me back to sanity. I was actually having a problem because I forgot to swap `export const handler...` to `exports.handler = ...` when I moved the lambda from typescript to javascript and got myself lost! – Nick Meldrum Jul 25 '19 at 19:44