question

anoop4real avatar image
anoop4real asked

AWS Lambda: Properly uploading a zip

I am writing a skill which requires aws-sdk, so I have created a zip with the below contents in root

index.js
node_modules
package.json

After uploading to AWS, inline editing was not available (that's understood). Now when I try to test my Alexa skill, I get the below error

Unable to import module 'index': Error
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

Looks like index.js is not getting found. I have put all the files in root and zipped

I then tried to upload a small project and below is my observation. By default when you create a function from scratch there is a folder created and when we upload the zip, on unzip there is a folder created again as part of unzip which is probably causing the issue, please see the screenshots below.

On Creation

After Zip upload

If inline editing is available, you can fix this by rearranging files, but if inline editing is not available, we cant fix it. Need urgent help on this

alexa skills kitlambdaaws
10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Arun Pattni avatar image
Arun Pattni answered

I've run into this issue before. The problem is the way that you are zipping it. You need to zip the files, not the folder. See the image below for what I mean

4 comments
10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi,

Thanks for the reply, I have tried with the files also, it will create a default archive folder when I compress it from MAC. Do I need to use 7zip?

-anoop

0 Likes 0 ·

@Arun Pattni

I tried again and it worked, thanks for the pointer

0 Likes 0 ·

can u please share the image once again

0 Likes 0 ·
Rokas avatar image Rokas newuser-64a41272-f9be-4eda-8d84-71a5b807515c ·

What problem are you having with zipping? Just zip the contents of lambda folder, not the lambda folder itself.

0 Likes 0 ·
anoop4real avatar image
anoop4real answered

Any pointers?

10 |3000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.