Activity - Create Lambda Function With S3-1
Activity - Create Lambda Function With S3-1
u Note that there will be 2 deliverables for this activity and is worth 2 points
Create 2 S3 Buckets 3
u To create a function, make sure you have “Author from scratch” selected
u Enter a name under “Function name”
u For “Runtime”, select Python 3.9
u Keep all other default settings and
click “Create function”
Create Lambda Function and add S3 Trigger 7
u Under the Configurations tab, click the “Edit” button under “General
configuration”
Create Lambda Function and add S3 Trigger 8
Click here
Create Lambda Function and add S3 Trigger 9
u Click “Add permissions > Attach policies”
Create Lambda Function and add S3 Trigger 10
u Type s3 to filter the policies and select “AmazonS3FullAccess”
u This will allow the Lambda function to have full access your S3 buckets
u Policies will be covered in a future class
u Click “Add permissions”
Create Lambda Function and add S3 Trigger 11
u Verify the policy has been added similar to what’s shown below
u Once your trigger has been added, you see a message indicating
your S3 bucket is receiving events
u Now we need to write the Lambda function to process the event
Create Lambda Function and add S3 Trigger 15
u Click the ”Code” tab and paste the Python code (s3-lambda.py), which can be found on
myCourses in Activity #13 – Create Lambda Function with S3
u On line 10, you need to add your destination bucket name
u On line 29, add your RIT name and put quotes around it
u Click the “Deploy” button to deploy your Lambda function. It is now live!
Test the Lambda Function 16
u Open S3 from the console and open the source bucket you have previously created
u Click the “Upload” button to upload a text file of your choice from your PC
u Take a screenshot and upload to Assignments > Activity #13 - Create Lambda
Function with S3
Deliverable #2 19
u Now that you have successfully created a Lambda function triggered by an S3 bucket, your next
assignment is to create a simple ”hello world” Lambda function that’s integrated with the API
Gateway
u When accessed in a browser (using the URL format below), it should display a message from your function
u You will need to do the following:
u Create a simple Lambda function (choose any programming language) that prints a simple ”hello world”
message with your RIT username
u No trigger is needed
u Create a publicly accessible API in the API Gateway that calls this Lambda function
u Your API should follow the same conventions used in the previous activity (see below)
u Submit the URL (paste in a doc) to Assignments > Activity #13 - Create Lambda Function with S3
Cleanup (only for Deliverable #1) 20
u Follow these steps to delete everything you have created for this activity
u When you are done, go back to the AWS console and select “Lambda”
u Select your lambda function and select “Actions” > “Delete” to delete the function
u When you are done, go back to the AWS console and select “S3”
u You will need to empty your buckets before you can delete them
u For Deliverable #2, do not delete your Lambda function or API until it is
graded
u Once graded, follow the above instructions to delete your Lambda
function
u Select your API and click “Actions > Delete”