AWS Lambda Part#3 | Trigger Lambda function using S3 and API gateway |Cloud Computing In Telugu
Contact details:
Telegram: https://t.me/cloudcomputingintelugu
Instagram: / cloudcomput. .
Gmail: [email protected]
00:00:00 - Channel Introduction
00:00:16 - Class introduction
00:00:50 - Trigger Lambda using S3
00:08:40 - Trigger Lambda using API Gateway
In this video, you will learn how to trigger a lambda function using S3 and API gateway.
/*================ S3copyfile Lambda function code ====================
import boto3
s3 = boto3.resource('s3')
def lambda_handler(event, context):
bucket = event['Records'][0]['s3']['bucket']['name']
key = event['Records'][0]['s3']['object']['key']
copy_source = {
'Bucket': bucket,
'Key': key
}
try:
destbucket = s3.Bucket('s3writedata')
destbucket.copy(copy_source, key)
print('{} transferred to destination bucket'.format(key))
except Exception as e:
print(e)
print('Error getting object {} from bucket {}. '.format(key, bucket))
raise e
================ Getpresignedurl Lambda function code ====================
import logging
import boto3
from botocore.exceptions import ClientError
import json
def create_presigned_url(bucket_name, object_name, expiration):
"""Generate a presigned URL to share an S3 object
:param bucket_name: string
:param object_name: string
:param expiration: Time in seconds for the presigned URL to remain valid
:return: Presigned URL as string. If error, returns None.
"""
Generate a presigned URL for the S3 object
s3_client = boto3.client('s3')
try:
response = s3_client.generate_presigned_url('get_object',
Params={'Bucket': bucket_name,
'Key': object_name},
ExpiresIn=int(expiration))
except ClientError as e:
logging.error(e)
return None
The response contains the presigned URL
return response
def lambda_handler(event, context):
logging.info(f"Recieved Event: {json.dumps(event, indent=4)}")
event_body = json.loads(event.get("body", json.dumps({})))
bucket_name = event_body.get("bucket_name")
object_name = event_body.get("object_name")
expiration_time = event_body.get("expiration_time", 3600)
if not bucket_name or not object_name:
response = {
"error_message":"bucket_name, object_name fields are must in body and expiration_time is optional."
}
else:
pre_signed_url = create_presigned_url(bucket_name, object_name, expiration_time)
response = {
"pre_signed_url":pre_signed_url,
"valid_for": f"next {expiration_time} seconds",
"bucket_name": bucket_name,
"object_name": object_name
}
return {
"statusCode":200,
"headers":{"Access-Control-Allow-Origin": "*"},
"body": json.dumps(response)
}
*/
Amazon Web Services(AWS) is a Comprehensive Evolving Cloud Computing Platform provided by Amazon that includes a mixture of infrastructure as a service.
What is Cloud Computing?
Cloud Computing in Telugu
Cloud Computing Technologies
Cloud Computing Technics
#awsintelugu #amazonwebservicesintelugu #cloudintelugu #cloudcomputingintelugu #besttechnologiesoncloudintelugu #computing#awscloudintelugu #whatiscloudintelugu #cloudtechnologyintelugu #cloudservicesintelugu #technologiesoncloudintelugu #technologyintelugu #howtoworkoncloudintelugu #intelugu #awstelugu #aws #amazonwebservices #cloud #cloudcomputing #besttechnologiesoncloud #computing#awscloud #whatiscloud #cloudtechnology #cloudservices #technologiesoncloud #technology #howtoworkoncloud #computing #cloud101 #cloudcomputer #computung101#developincloud #bigenterprise #cloudplatform #cloudoncomputer #microsoftcloud #microsoftcloudservices #services #MicrosoftAzure #AzureisMicrosoft #bigenterprisecloud #companiesaws #offeredonPaaSserviceandIaaSservice #PaaSservice #IaaSservice #featuredservices #datacenter #databases #amazon #amazonworlds #mostcomprehensiveandbroadlyadoptedcloudplatform #featuredservicesfromdatacenterglobally #WhatcompaniesusAWS#WhatcompaniesusAWS? #cloudbasedtechnology
Watch video Day#28 | AWS Lambda Part#3 | Trigger Lambda function using S3 and API gateway |CCIT online without registration, duration hours minute second in high quality. This video was added by user Cloud Computing in Telugu 06 June 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 12,778 once and liked it 185 people.