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.

Wednesday, December 6, 2017

Installing AWS CLI on Centos

How to install AWS CLI on Centos?

AWS CLI helps you a lot to interact with your AWS resources through CLI. This is good if you are an experienced person. As a pre-request, you need Python 2 version 2.6.5+ or Python 3 version 3.3+ in your machine.

1. Login to the server.
2. curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
3. unzip awscli-bundle.zip
4.
./awscli-bundle/install -b ~/bin/aws
5.  aws --version
 

Monday, December 4, 2017

Nomad Error:FIX

How to solve this Nomad Error.

Error submitting job: Unexpected response code: 500 (rpc error: 11 error(s) occurred:

* Task group <TASK_NAME> validation failed: 1 error(s) occurred:

* 1 error(s) occurred:

* Max parallel can not be less than one: 0 < 1
* Task group <GROUP_NAME> validation failed: 1 error(s) occurred:

* 1 error(s) occurred:


I am using Nomad version 0.7.0

Solution:

In my job stanza, I need to add max_parallel count

update {
   
    stagger = "10s"
   
    max_parallel = 2
 
    }


For more details, read here