Currently, I am writing a Lambda function that triggers when a new s3 bucket is created (under my project).
I am using a cloudwatch function which triggers the lambda function.
I have to pass the whole event to the lambda function as input. What do I do to get my Lambda function so that it can read the bucket's name from the event and assign the name as the value to a string variable?
I am using this code below, I have written it myself, might be some mistakes, please correct me where I am lacking and I need to do to accomplish the task that I have mentioned above, thanks in advance and yeah now take a look at my code below:
import boto3
from botocore.exceptions import ClientError
s3 = boto3.client('s3')
def lambda_handler(event, context):
bucket = event['s3']['bucket']['name']