Skip to main content

S3 Bucket events to trigger lambda function

 AWS Lambda:

     It lets you run code without provisioning or managing servers. You pay only for the compute time you consume.

With Lambda, you can run code for virtually any type of application or back-end service - all with zero administration. Just upload your code and Lambda takes care of everything required to run and scale your code with high availability. You can set up your code to automatically trigger from other AWS services or call it directly from any web or mobile app.

 


 

 

Creating a Lambda Function:

 

step1: select lambda service from services

 
 
step2:  
        1. Give appropriate function name
        2. select runtime environment (i am working on python3.6)
        3. click on change execution and select Create a new role from AWS                     policy templates
       4. Give appropriate role name and in template drop-down select s3 read              only  access
        5. Create function click 

lambda creation
lambda creation


    After successful creation:

lambda_function

 

 Creating S3 Bucket:

     Amazon S3 Access Points simplifies managing data access at scale for applications using shared data sets on S3. With S3 Access Points, you can now easily create hundreds of access points per bucket, representing a new way of provisioning access to shared data sets. Access Points provide a customized path into a bucket, with a unique host-name and access policy that enforces the specific permissions and network controls for any request made through the access point.
 
step1: In services select the s3 simple storage
 
step2: create the bucket with the proper name(unique name)
 
 
 
bucket creation
Bucket creation

 
 
step3: after creating the bucket, go to bucket and select properties
bucket_properties

 
 
step4: select events and click on add notification
step5: Select appropriate event name
step6: If the you want to trigger the lambda when ever new files is uploaded into  s3, then select the put.
step7: On send to drop down select lambda_function
step8: In lambda function drop down select the lambda function which you have created earlier
step9: click on save . it will create an event for you lambda function
event creation



 after saving the event:

 

check the lambda function weather the storage is added or not

 
after successful addition of s3

Comments

Popular posts from this blog

MQTT set up Flask

 MQTT Introduction: It is message broker which holds the data when ever a consumer will connected to the topic then he will receive the data . mqtt is a machine to machine message broker, mainly used in IOT application, the default port is 1883   Installation: sudo apt-get update sudo apt-get install mosquitto Command line execution: Producer mosquitto_pub -h 127.0.0.1 -t 'topic_name' -m '{'name':'Sony'}' Subscriber mosquitto_sub -h 127.0.0.1 -t 'topic_name' -h : it is the host address -t : topic name -m : message payload QOS in MQTT: QOS(quality of services) there are mainly 3 services are available in mqtt  qos=0 qos=1 qos=2 QOS (0,0): At most once service, publisher will send a message to broker at most once, the broker passes a message to subscriber one time     

Making a Geographic Heatmap with Python

      We have a requirement like need to create a map where user is traveled.There are many libraries available in python to draw a map if you have list of co-ordinates with you like(longitude and latitude)  To name few packages : vincent, bokeh, plot.ly and matplotlib and folium   Things to consider while choosing the library: 1. Open source 2. Painless to use 3. built in support for heat-maps 4. actively maintained Folium is the lib which will satisfy above all use cases Requirements: pip install folium pip install geopands (for adding other geo json files) pip install pands (to read csv of excel files which are having the co-ordinates data) Creating the map: import pandas as pd import folium from folium.plugins import HeatMap map_df = pd.read_csv('map.csv', sep='\t') max_amount = float(map_df['Amount'].max()) hmap = folium.Map(location=[42.5, -75.5], zoom_start=7, ) hm_wide = HeatMap( list(zip(map_df.lat.values,         ...

CommandLine Args In Python

 Command line args in Python :      When the program comes to Python , it's all about libraries .Argparser is the library used for the taking inputs from the command line. Here you can validate the arguments which are entered by the user without writing the another function to validate from the if conditions. suppose give a filename like cmdprocess.py You can give the expecting arguments like below cmdprocess.py --help      it will give the total arguments with respective commands to represent Required =True :           When the required is true. You have to enter the argument.   Type = function name:          Type is very useful to validate the input entered by the user. so that you can send a message like user need to enter the defined arguments only. This function always expects the input argument . Custom-Exceptions In Python:    There are multiple exception...