Wednesday, July 8, 2020

AWS Lambda Python - Build from your local machine - Upload as zip file - boto3 - import modules - Linux - Ubuntu

Hi Folks,

Now everything is PaaSified :)

So today we are going to looking in to creating and deploying AWS Lambda - Python from ZERO.


Here we go...



Step1. Create a new AWS Lambda using AWS portal or AWS CLI

Step 2. Install Python and pip in your local machine

Step 3. Create a new folder in your local machine

Step4. create a new file YOUR_FILE_NAME.py in that folder

Step5. Do some coding in that file

Sample code
import json print('Loading function') def lambda_handler(event, context): print("This is from Lambda ") return "Lambda Executed Successfully !"

Step7. Save the file

Step8.  Install boto3 modules for making python function ready

pip install boto3 -t ./

Step9. Make a ZIP package with correct file permissions



cd YOUR-FOLDER-NAME
chmod -R 755 .
zip -r ../myDeploymentPackage.zip .

Step10. Upload myDeploymentPackage.zip in Lambda using AWS portal or AWS CLI


  1. Open the AWS Lambda console.
  2. Choose Functions on the navigation pane, and then open your function.
  3. In the Function code section, expand the Code entry type drop-down list, and then choose Upload a .ZIP file.
  4. Choose Upload, and then select your .zip file.
  5. Choose Save.
  6. Choose Test.
You can also upload your .zip file from the AWS Command Line Interface (AWS CLI) using the update-function-code command.


Step11.  Make sure that you have proper settings


Handler should set as YOUR_FILE_NAME.YOUR_HANDLER_METHOD_NAME

For example

If you saved your file as "lambda_function.py" and the handler method is  "lambda_handler(event, context)" you should set "lambda_function.lambda_handler" as Handler in settings. Otherwise you will get error.


Same like step8 you can install any other modules for your code.


You are all set... All the best ! Happy Coding...!!


Saturday, July 4, 2020

Eclipse taking lot of network and time to import maven projects ? Here is the simple trick

Hi Folks,

By default maven option will be on for downloading sources and docs. This will take more network and time to import maven projects.

So disable it.

Window > Preferences  > Maven
Disable Download Artifact Sources
Disable Download Artifact Javadoc

So the final settings of maven preferences will be like :



Thanks :)


Thursday, June 25, 2020

How to check a port is open or not in pod

In kubenetes cluster, sometimes we may force to debug. It may be related networking, checking open ports, API availability etc.


So here is the simplest way to do this,


1. Create another pod for debugging

kubectl run curl1 --image=radial/busyboxplus:curl -i --tty -n YOUR_NAMESPACE
This will create a new pod in the specified name space and it will enable a command line for typing any command supported by linux

If you don't see a command prompt, try pressing enter.
[ root@curl1-5955d6546b-p5pm2:/ ]$ 

telnet will be enabled by default 

So you can try to telnet to your service which is running in kubernetes cluster.