504344 (14) [Avatar] Offline
#1
Hello,

followed instruction and created function.
Upload of image works fine. Not thumb is generated and I do not find anyting in log.

Policy_CreateThumbnailAndStoreInDB

is added to role.

Please help how to debug.

Thanks
148705 (1) [Avatar] Offline
#2
I've got this working, the trick was using the same version of node locally matching the version in Lambda, which is node 6.10.

I used a node version manager to install the node 6.10 version:
https://github.com/creationix/nvm

Then, I did a (within the createThumbnailAndStoreInDB-js directory):
npm install async --save
npm install aws-sdk --save
npm install gm --save
npm install util --save


I removed the package.json file, zipped up:

index.js and the node_modules directory

And, it started working!

FearNoFailure (1) [Avatar] Offline
#3
im getting similar issues. i went through the steps to use nvm to downgrade to json 6.10. i cant save my lambda function in the web console, and it says "fix errors before saving", however nothing below is being flagged as an error. my guess is that the zip package isnt taking for some reason. i ran npm install, as well as the separate installs you suggested. in my zip, i have index.js and node_modules (dir).

edit:
went into S3 into the trigger section. invoked the lambda function from there. it had objects deleted instead of objects created selected in there. switched it around and it worked. weird thing is that i swear i selected objects created (all) from the lambda side of things. anyone else run into this? am i crazy? great book so far!
DeMoehn (10) [Avatar] Offline
#4
If your Lambda function is opened, next to the "Configuration" tab there is "Monitoring".
There you can see if your Lambda function ran successfully or if you had any errors.
If you DON'T have any errors, it seems like you have a problem with your trigger as "FearNoFailure" described above.
If you HAVE any invocation errors, click on "Jump to Logs".
The Script is written to give you some pretty good information, what's going wrong.

CloudWatch gives you some detailed information, too.
The output from your script can be found between the "START" and "END" Messages.
504344 (14) [Avatar] Offline
#5
screen.JPG
[ 216 KB ]
Thanks to your answers so far, unfortunately it does still not work at my side. I did already

1.) downgraded fro 6.11 to 6.10.0 of node js and created zip file

2.) followed instructions regarding npm install by 148705

3.) corrected wrong index.js code according to errata

4.) uploaded new zip to new created lambda function

5.) added new images to S3 via Upload

6.) double checked policy regarding access to S3

7.) double checked lamba function S3 trigger is set to "Event type: ObjectCreated (All)" with "Prefix images/"

8.) checked if delete of image triggers something - nope

9.) checked log files

Unfortunately log files in monitoring are not very helpful at least for me. My event just times out.

Event triggered

2018-01-03T14:33:14.221Z 2b060bd6-f091-11e7-9b23-45d9e6813131 Reading options from event:
{ Records:
[ { eventVersion: '2.0',
eventSource: 'aws:s3',
awsRegion: 'eu-central-1',
eventTime: '2018-01-03T14:19:53.918Z',
eventName: 'ObjectCreatedsmilieut',
userIdentity: { principalId: 'XXX' },
requestParameters: { sourceIPAddress: '85.178.105.70' },
responseElements:
{ 'x-amz-request-id': '1CD49EE8019DCAD0',
'x-amz-id-2': 'Rh6Ye6Ncd/fhGT0U1fJqEEc6fckOoJhbOR4VM6CygInUiU5mHOchgOMHTziruNgu57U7LtFWRv4=' },
s3:
{ s3SchemaVersion: '1.0',
configurationId: '59fe57fc-75a3-4778-964f-f6be724491ef',
bucket:
{ name: 'new-pictures',
ownerIdentity: { principalId: 'XXX' },
arn: 'arn:aws:s3:::new-pictures' },
object:
{ key: 'images/NeapelAmalfi-39.jpg',
size: 1785807,
eTag: '154b89a148a76928a70cd573a50d809b',
sequencer: '005A4CE689DE4E6EDE' } } } ] }


and 3 seconds later time out without entry in database nor thumb image created

2018-01-03T14:33:17.064Z 2b060bd6-f091-11e7-9b23-45d9e6813131 Task timed out after 3.00 seconds


I attached screeshot for complete log entries for this try.

Any help / suggestion is appreciated.
DeMoehn (10) [Avatar] Offline
#6
That‘s ab easy one.
Your function just timed-out, because your function timeout is still 3 seconds.
Increase the timeout of your lambda function to e.g. 10 seconds
504344 (14) [Avatar] Offline
#7
Unfortunately not

2018-01-03T15:45:45.812Z af35ea59-f09c-11e7-8417-bbb6fde68b2a Task timed out after 10.01 seconds

It just times out after 10sec.
DeMoehn (10) [Avatar] Offline
#8
Hmmm...
Too bad. I hoped it's that easy.

I guess you already tried to increase it even more and/or give it more memory??
504344 (14) [Avatar] Offline
#9
You were damn right. I extended memory to 256MB with 1 min timeout and now it works.

I double checked with 128 MB and 1 min it does not work with my sample <2 MB jpgs. So folks out there, give it some more juice and it works.

Thanks for your help!
DeMoehn (10) [Avatar] Offline
#10
That's great, I'm glad it worked out for you =)
I have 320MB and 10sec and a 4MB picture just worked great.
Just tried (out of fun) a 34,3MB picture and it needed >800MB and 16s.

So if anyone has a timeout, increasing memory and time is a good idea smilie