Saturday, December 16, 2017

Handler 'handler' missing on module 'copy': module 'copy' has no attribute 'handler'

In my AWS Lambda function I am getting the following error in cloudwatch.

 Handler 'handler' missing on module 'copy': module 'copy' has no attribute 'handler' 

I am using a zip upload function, with Python 3.6.

 Solution:
Here the fix is how we call the handler. Its name.

In my case, I have renamed the copy.py to index.py
Inside the index.py, I have a function - def handler(event, context):

So my lambda handler is : index.handler
ie. Module.Function (filename.function_name)

Zip the folder and upload to lambda. See this blog for zip
 

Wednesday, December 13, 2017

errorMessage": "Cannot find module '/var/task/CreateThumbnail'

When I worked with AWS lambda function for creating a thumbnail for images uploaded to a S3 bucket. I am facing the following error while lambda test.

 errorMessage": "Cannot find module '/var/task/CreateThumbnail'

The reason for this issue is because of non proper zip the contents that we uploaded to lambda function.

zip -r ../yourfilename.zip *

Your folder may contain your index.js, node_modules, etc. files. Upload the new yourfilename.zip in your lambda function and try to run the test, the issue got fixed.

Monday, December 11, 2017

TypeError: csv is not a function in Nodejs

I am getting the following error in Nodejs, when I use a csv module.

TypeError: csv is not a function
    at Object.<anonymous> (/root/app.js:4:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:383:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:496:3


Here is my npm list:
[root@machine2 ~]# npm list
root@1.0.0 /root
├── csv@2.0.0 extraneous
└─┬ debug@3.1.0
  └── ms@2.0.0

 
Solution for this issue:
You need to remove the curret csv module and need to instll csv@0.3.7 which will solve this issue. Below given steps will surely help you.
 
[root@machine2 ~]# npm remove csv
- lodash.get@4.4.2 node_modules/lodash.get
- csv-generate@2.0.0 node_modules/csv-generate
- csv-parse@2.0.0 node_modules/csv-parse
- csv-stringify@2.0.0 node_modules/csv-stringify
- stream-transform@1.0.0 node_modules/stream-transform
- csv@2.0.0 node_modules/csv
npm WARN root@1.0.0 No description
npm WARN root@1.0.0 No repository field.
 

[root@machine2 ~]# npm list
root@1.0.0 /root
└─┬ debug@3.1.0
  └── ms@2.0.0

[root@machine2 ~]# npm install csv@0.3.7
root@1.0.0 /root
└── csv@0.3.7
npm WARN root@1.0.0 No description
npm WARN root@1.0.0 No repository field.
[root@machine2 ~]#


It works!
 

Thursday, December 7, 2017

Error on starting Consul

My Consul client is not able to start the consul service. Its getting the following error
Consul version is Consul v1.0.0 

WARNING: LAN keyring exists but -encrypt given, using keyring
==> Starting Consul agent...
==> Joining cluster...
==> 5 error(s) occurred:

* Failed to join 192.168.1.10: No installed keys could decrypt the message
* Failed to join
192.168.1.11: No installed keys could decrypt the message
* Failed to join
192.168.1.12: No installed keys could decrypt the message
* Failed to join
192.168.1.13: No installed keys could decrypt the message
* Failed to join
192.168.1.14: No installed keys could decrypt the message

Solution for this issue:

1. cd $consul-data-dir/serf
2.  Added the current encryption key in "local.keyring"
3. Start consul

It works. In my case I have two data center. One data center's encryption key is missing in file  "local.keyring". After updating and restarting it works fine.