Overview
Lab details
- This lab walks you through the creation and usage a serverless AWS service called AWS Lambda. In this lab, we will create a sample Lambda function to be triggered on an S3 Object upload event. The lambda function will make a copy of that object and place it in a different S3 bucket.
- Duration: 30 minutes
- AWS Region: US East (N. Virginia) us-east-1
Architecture diagram

Task details
- Sign in to AWS Management Console.
- Create two S3 buckets.
- Create an IAM Policy.
- Create an IAM Role.
- Create a Lambda function to copy the object from one bucket to another bucket.
- Adding triggers to Lambda function.
- Test the Lambda Function.
- Validation of the lab.
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time
Files you need
Download these before you start — the lab cannot be completed without them.Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console button, and you will get redirected to AWS Console in a new browser tab.
- On the AWS sign-in page,
- Leave the Account ID as default. Never edit/remove the 12 digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
- Now copy your User Name and Password in the Lab Console to the IAM Username and Password in AWS Console and click on the Sign in button.
- Once Signed In to the AWS Management Console, Make the default AWS Region as US East (N. Virginia) us-east-1.
Task 2: Create Two Amazon S3 Buckets
In this task, we will create two AWS S3 buckets i.e the source bucket and the destination bucket by providing the required configurations like name, region etc.- Navigate to the Services menu in the top, then click on S3 in the Storage section.
- Click on Create Bucket button.

- Bucket Name: Enter mysourcebucket1234567
Every S3 bucket name is unique globally, so create the bucket with a name not currently in use.

- Leave other settings as default and click on the Create bucket button.
- Copy the name of the bucket and save it in a text file for later use.
- Click on Create bucket button.
-
Bucket Name: Enter mydestinationbucket1234567
Note: Every S3 bucket name is unique globally, so create the bucket with a name not currently in use.

- Leave other settings as default and click on the Create bucket button.
- Copy the name of the bucket and save it in a text file for later use.

- Now we have two S3 buckets (Source and Destination). We will make use of our AWS Lambda function to copy the content from source bucket to destination bucket.
Task 3: Create a Lambda Function
- Make sure you are in the US East (N. Virginia) region.
- Go to the Services menu and click on Lambda under Compute section.
-
Click on the Create a function button.
- Choose Author from scratch
- Function name : Enter mylambdafunction
-
Runtime : Select Python 3.13

- Expand Advanced Settings, then Enable Custom execution role option.

- Click on the Create function button.
- If you scroll down a little bit, you can see the Code source section. Here we need to write a Python function that copies the object from the source bucket and paste it into the destination bucket.
-
Remove the existing code in AWS lambda lambda_function.py. Copy the below code and paste it into your lambda_function.py file.
- You need to change the source and destination bucket name in the index.js file line number 5 & 6 which we copied earlier.
-
Save the function by clicking on Deploy button.

Task 4: Adding Triggers to Lambda Function
-
Scroll up to go to Function overview and click on + Add trigger button.

- Scroll down the list and select S3 from the trigger list. Once you select S3, a form will appear. Enter these details:
- Bucket: Select your source bucket - mysourcebucket1234567
- Event type: Select All object create events
- Leave other fields as default.
- And check the option of Recursive invocation to avoid failures in case you upload multiple files at once by Checking the acknowledge option.
-
Click on Add button.

Task 5: Test Lambda function
-
If you have a test image on your local machine, you can use that image.
-
Click on Download Me to open the image in new tab, right click the image and save it to your local.
Note: Please name the image file as “image.jpeg” without using variations like “image (2).jpeg”.
-
Click on Download Me to open the image in new tab, right click the image and save it to your local.
- Go to S3 Bucket list and click on source bucket - mysourcebucket1234567.
-
Upload image to source S3 bucket. To do that:
- Click on the Upload button.
- Click on Add files button to add the files.
- Select the image and click on the Upload to upload the image.
- Now go back to the S3 list and open your destination bucket - mydestinationbucket1234567.
- You can see a copy of your uploaded source bucket image in the destination bucket.
Optional: Debugging Lambda Function Using CloudWatch
If you encounter errors such as the source file not being copied to the destination S3 bucket, please debug your Lambda function by following the steps mentioned below:- From the AWS Management Console, navigate to the CloudWatch service.
- In the left sidebar, under the “Logs Management” menu, select “Log groups.
- Select your Lambda function’s log group, which should be in the format /aws/lambda/function-name.
- Choose a log stream to view its logs.

- In the list of Log events, select the right arrow next to the Timestamp to expand the details for that event.

Validation Test
- Once the lab steps are completed, please click on the Check my work button on the left side panel.
- This will validate the resources in the AWS account and displays whether you have completed this lab successfully or not.
- Enter the source bucket name and destination bucket name in the user input fields and click the Check my work button.
-
Sample output :

Do you know ? AWS Lambda has a generous free tier that allows you to run up to 1 million requests and 400,000 GB-seconds of compute time per month for free, making it an ideal choice for small-scale projects and experiments.
Completion and conclusion
- You created two S3 buckets acting as source and destination.
- You created an IAM policy and role that will be used for the Lambda function.
- You have successfully created an AWS Lambda function and configured an S3 trigger.
- You have successfully triggered the Lambda function to copy an image from the source S3 bucket to the destination S3 bucket.
End lab
- Sign out from the AWS Management Console.
- Click on End lab button in the IP Lab Portal and wait till the process gets completed.
What gets checked
When you press Check my work, the platform verifies each of these:- Create Private S3 bucket — Check whether a private S3 bucket is created or not
- check s3 object — Check whether an object is uploaded to the S3 bucket.
- Create an AWS Lambda Function — Check whether a Lambda Function is created or not