AWS Lambda
AWS Lambda
AWS Lambda
Allows you to execute your code without server. It is a Platform as a service (PAAS), where you can
choose environment, push the code and run it.
Why Lambda:
1. Serverless architecture
2. No virtual machines to be created
3. Monitor performance
4. Code freely
How it works:
When we upload the code to lambda, it executes the code on a predefined server. Once the code is
triggered, lambda will help in provision and managing.
print('Loading function')
s3 = boto3.client('s3')
# Get the object from the event and show its content type
bucket = event['Records'][0]['s3']['bucket']['name']
key = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8')
try:
response = s3.get_object(Bucket=bucket, Key=key)
print("CONTENT TYPE: " + response['ContentType'])
return response['ContentType']
except Exception as e:
print(e)
print('Error getting object {} from bucket {}. Make sure they exist and your bucket is in
the same region as this function.'.format(key, bucket))
raise e
))))))----------------------------------------------------------------------------------------------------------------
Add trigger
Select trigger
S3
Select bucket name from S3 (Create a S3 bucket)
All object create event
Check-in box for recursive loop
Click add
Open S3
Upload something to bucket
Open Lambda function
Monitor
Invocation shows as 1 due to one item added in S3 bucket
Log
Log stream
You can see the type of document
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: