0% found this document useful (0 votes)
18 views5 pages

Aws LAMBDA

The document provides an overview of AWS Lambda, emphasizing its serverless architecture, cost optimization, and event-driven capabilities. It explains the differences between Lambda and EC2, detailing how Lambda automatically scales and eliminates server management responsibilities. Additionally, it covers how to create and configure Lambda functions, including the use of environment variables, triggers, and layers for code management.

Uploaded by

sagarmanikanta94
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

Aws LAMBDA

The document provides an overview of AWS Lambda, emphasizing its serverless architecture, cost optimization, and event-driven capabilities. It explains the differences between Lambda and EC2, detailing how Lambda automatically scales and eliminates server management responsibilities. Additionally, it covers how to create and configure Lambda functions, including the use of environment variables, triggers, and layers for code management.

Uploaded by

sagarmanikanta94
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

LAMBDA abhishek class -17-18

code<java,python .net,golang >=========LAMBDA<excuter> ==========<output>=


why we use lambda
1. no serverssetup
2. no start or stop
3.no additional cost
4 serverless

HOW TO CREATE BASIC LAMBDA:servce as function we use lambda forb projects such as
cloud optimization
it is primary respones for devops engineer we can triggered lambda functions with
wide range of serveieces like
s3 and cloud watchwe can perform activities which are basically called as event
driven actions.
fundamentals and architexure of lambda and difference of lambda and ec2
LAMBDA:1.compute:aws will automatically create compute foryou defending upon your
requiermentsn and automatically scallup and scale down aplication once task is
done aws scale down the lambda
2.serverless
ec2 instance is pay-as -you go model and we are respons ble for scaling and upgrade
the patches manually and scale down the application manually.but lambdapoint of
there are noserver we are not bothering about servers. once the requierment is
there aws can crestae serecver for you
once requierment don aws can tear down the server for you . it is majer diffrence
of ec2 and lambda

ONEmore thing wehave getting private and public ip address with ec2 instances but
lambda point of view we cant get any ipadress. even we can not knoew it tis lambda
where this created where this availbleinstances and details about lambda
funtions.ec2 version of view we acn control subnets ip adreess and security rules
autoscalling
note: as adevops engineer we cant define serverless or server computing for
applications hosting .majorly the dev team and infrastucure team and architectteam
can decide it.
AS Adevps engineer we are work is crete lambda function or create the infrastucture
only your resons blity.as devos engineer we can use lambda fir cost optimization
like identify the stale resources and delete it or send anotification to teams
in lambda only run event driven not manually so we can configure with cloud watch
and it will trigger the task partiqular time on everyday.
SOME OF THE BEST STGES FOR USING AWS LAMBDA SERVERLESSS FUNCTIONS:
1.COST OPTIMIZATION
2 SECURITY/COMPLIENCE
3.
EBS/TYPES:1.GP2/2.GP3
how to create lambda from ui
author scrach: write from code scratch
use ablue print:this samples is provided by aws its help to developers and devops
engs
trigger alambda function is on aobject is created undervaws s3 bucket t is valid
use case.
ww notified whenever object is created under s3 the we triggerd lambda function.
we can write own code on our personal laptopalso instaed of writing here.we can
crete docker image out of the code and we can use image here
and push image to ecr
primerly supportlanguages:
go
python
ruby
nodejs
java
shell script is not supported
how to crete:

function name: name mention here


runtime: select programmig language
enable function url: its help to giving ip and expose appication from out side
acess: swlect iam user OR any one can acessit
create lambda

HERE IS TWO OPTIONS AFTER CREATING


1. ADD TRIGGER: it is use most of the times it is aevent driven it can cloud watch
trigger everyday a point of time it can be a api call on cloud watch whenever a ebs
volume is created trigger the lambda function or it can be triggerfrom s3 s3 have
also something called event triggering so you or some othervserice also supported.
othervise wecan do manually.

lambda_handler: we called it every function


note :we can customize it but its internally us

ing lambda_handler
note: default function name lambda_ handler UNTIL WE CUSTOMIZE IT.
we can add files and we can add folders also
we can wright code in terminal also other vise we can also use zip file for up
lodinfg from any where

HOW TO COTROL LAMBDA FUNCTIONS: LAMbda supportin environment variables


configuration===environment variables==add the envs
WHENEVER FUNCTION CALLED OR YOUR ONTHE COMPUTE THAT EC2 CREATING WHENEVER functions
get called you can tweak that values from the env so tomorrow you can modify the
codejust nmodify the env variables
===================================================================================
==================
configuration
triggers
permissions: who can acccess the lambda functions whenever we cerated a function
aws has been create role for you you can use it in permisssionlevel eigher using
existing one or create new role ncrese permissions
2. ADD DESTINATION:this lambda function has some destination like sns or it's want
put some information
you awant send some out put for your lambda function then you can use it. use
function url get aceess it when i enable http aceess so this is my function we can
cretelambda in partiqular vpc you can put that it can serviceacccesssble with in
vpc only
service with in the vpc can also access the lambda function also
any other like syck-asynk data-proxy is noyt importent
===================================================================================
=================================================
rahul wagah AWS LAMBDA=PRACTICALS=COST OPTIMIZATION

aws lambda is a excuter taking input and genrate the output it is diffrent from
tradtional ec2 instances.
how to use realtime into lambda
note
WE NEED DEFINE 'IMPORT' FOR PRPRER LIBRRIES WE WANT USE
'LAMBDA_HANDLERS' is mandatery for writing handling function
'return repons' stsus code
zip file: its need librfary defendaries also
FIRST WENEED TO INSTALL PYTON DEFENDERIES
$pip install -r requierments.txt
then compress .py file ,read.md, requierment file make it zip file
and we need go to console of lambda
select upload file : select from local zip file
after that lambda function file name <not change handler name>

how upload from s3 bucket


create a bucket and up load the ;local zip file and after that copy zip file url
and paste into lambda s3 function url and test it
how to enable url: go to configuration select ==1.none: its also createa policy
2aws_iam===its for restrict the access with out authencation === in real time we
use iam only

how to secure url:


select aws _iam type we need to provide aws iam creditiels here
in this senario we using post man api for aceesing with creditiels
select lambda function url paste in to postman <application> and select aws
signature provide accesskey and secret key,region,servicename,clicksave wecanget
code input of lambda function

AWS LAMBDA VERIABLES ITS IMPORTENT TONUSE IN LAMBDA FUNCTIONS IN AWS LAMBDA

this env is configure for my lambda

CREATE FUNCTION NAME= lambda_with_env_variable

runtime:
archiexrure:
configurestion==>envariables========>edit>add>

KEY VALUE
MY_env_VARIABLE random_VALUE_from_ENV
how to wrte file

import json
import os
def lambda_handler(event,context):

my_var_value=os.environ.get("MY_env_VARIABLE")
# 1000 implement

return{
'statusCode':200,
'body':json.dumps('aws lambda with environment variables='+my_var_value)

}
click on daploy and test
event name: test_event_env_var
private
event json
remove all
put only down symbal
{}
NOTE: we can create more envari
bles in side the lambda and we can pass it inside lambda function
LAMBDA_layers
Layers: lambda1
custom library lambda2
layer as library for your lambda function.layers can act as librery for your
lambda function library we called as alayer it can create one time and we acn use
multiple times with multiple lambdas rthat will sav he time to you and that will
give you
more standrization for lambda function managment.

how to create layers for lambda


click on layers====create layers
name:
description
upload zip file
runtime:
archtexure:

how to create in local


we need to upload directly or s3 bucket
rules for layer
if python
python>lib>python 3.12>site-packages>my_module>1.init.py2.my_function.py
create zip file
go to aws console upload zip file
click on create

remember
version
arm

create lambda function


in cretion tim use
layers
layers type
aws layer >> default layers
custom layer>>select layers with arn
specify an arn >>select this or customlayer

REMEMBER THIS
name of the module//1
name of the file//2
function neme//3
EXAMPLE:
import json
from my_module. my_function import function_from_lambda_layers
1 2 3

def lambda_handler(events, context):

result = function_from_lambda_layers

# 1000 implement

return{
'statusCode':200,
'body': json.dumps('hello from Lambad! =' +result)

test
eventname
private

remove all things and put empty like this


1 {}
and save it

test it

we use multiple lambda functions use this import line

You might also like