Thursday, October 1, 2020

Good resources to get started with AWS Lambda (python)

This blog is the collection of the articles I have referred to get myself hands dirty with AWS Lambda. I have meticulously referred and personally tried each of these articles, before listing them here.

I have personally focused on articles dealing Lambda functions in Python programming language, since Python is my first preference programming language.

Begin with ....

The following list of articles enables to get a quick introduction to AWS Lambda 
  • The AWS Lambda Tutorial gives a broader introduction to Lambda, particularly the need for it, the building blocks associated with it (Lambda function, Event Source, Log streams), comparison of Lambda with EC2 and Elastic Beanstalk, benefits, limitation, pricing, use-cases and finally a simple Hands-on example. But it's better to follow the hands-on example from AWS documentation given in the next bullet point, since the instructions in this page is not up-to date.
  • The Create a Lambda function with the console is a quick tutorial from AWS, to get hands dirty. It takes less than 5 mins to complete the instructions. This is very basic and you'll not have much fun at the end of it.
  • The AWS Lambda with Python: A Complete Getting Started Guide is a better example to start. It demos the use of environment variables and the process to encrypt secret values using AWS KMS and then decrypting the encrypted values in lambda function. The code sample to decrypt didn't work for me, the below code worked, which is generated by AWS itself while encrypting the env variable.

import os
import boto3
from base64 import b64decode

DB_HOST = os.environ["DB_HOST"]
DB_USER = os.environ["DB_USER"]
 
ENCRYPTED = os.environ['DB_PASS']
DECRYPTED = boto3.client('kms').decrypt(
    CiphertextBlob=b64decode(ENCRYPTED),
    EncryptionContext={'LambdaFunctionName': os.environ['AWS_LAMBDA_FUNCTION_NAME']}
)['Plaintext'].decode('utf-8')


def lambda_handler(event, context):
    print("Connected to %s as %s" % (DB_HOST, DB_USER))
    print("and the secret is %s" % DECRYPTED)
    return None

Step-up ... 

The tutorials in the previous section just dealt with creating Lambda functions from AWS console UI and triggering them from the 'Test' interface from the same console UI. The next set of tutorials guides about triggering the Lambda function with an http endpoint provided by api gateway.

Articles to refer further

6 comments:

sonnu said...

Nice Post!

Very good content about Aws lamba
AWS Architect Training
AWS Training

saketh321 said...

A great website with interesting and unique material what else would you need. ExcelR Data Science Course In Pune

MLM SCRIPTS said...

Nice post and valuable knowledge . Check our website too which has good information.

This Open source project management script is mainly designed for the people to make the business project management and to manage the task module and the project planning efficiently, because nowadays there is a huge need in small and medium business firm industry for project management site.

anupriya said...


I am regular reader of your blog and no doubt it all stuff is awesome. The best thing about your sharing and posting is that you always provide content that is helpful for both the newbie and experts.If you want to run your business perfectly then go for the Open Source Project Management script, it helps to manage the task module,event management, to maintain the project task of the individual person and project planning and etc...they are developed this script to solve these problems with user attraction templates, to make the business communication effectively.
Open Source Project Management script

menkjain636 said...

valuable content power bi training

upGrad Campus said...

Nice Post!!
Please look into this-
Are you ready to unlock your potential and take your career to new heights? Look no further than the Business Analyst Course at upGrad Campus. Designed for ambitious professionals like you, this comprehensive program equips you with the skills and knowledge needed to excel in the dynamic field of business analysis.