NET702: Lab 8 AWS Lambda

Task 1: Creating a Lambda function

Step 1: Open Vocareum -> Click on the lab -> My Work -> Start Lab. A pop-up window will appear and when it says, “Lab status: ready”, close the window -> Click on AWS tab on top right navigation bar.

Step 2: Click on “Service” -> Select “Lambda” -> Click on “Create function”

Step 3: In the “Create function” screen, select “Author from scratch”, enter the function name as “myStopinator”, runtime as “Python 3.8” -> Click on “Choose or create an execution role” -> Select “Use an existing role” from the drop down menu. In the dropdown list from “Existing role” select “myStopinatorRole” -> Click on “Create function”.

Task 2: Configuring Trigger

Step 1: Click on “+ Add trigger” -> Click on “Select a trigger” and choose “CloudWatch Events”.

Step 2: Click on “Create a new rule” and enter the rule name as “everyMinute”, rule type as “Scheduled expression”, scheduled expression as “rate (1 minute)”. -> Click on “Add”.

Task 3: Configuring Lambda function

Step 1: Click on “myStopinator” in the “Design” box. -> Delete the existing lambda code in the “Function code” box. Copy and paste the code given in the lab instruction into the “Function code”. Inside the code, configure, <REPLACE_WITH_REGION> to “us-east-1”. Replace <REPLACE_WITH_INSTANCE_ID> with the instance ID from the Instance in the EC2 -> Click “Save” from the top right corner. Click on “Monitoring” to view the charts of no. of times function was invoked, error count, etc.

Task 4: Checking if Lambda function worked

Step 1: After task 3, go to “EC2 console”, you will see that the instance has stopped. If you try to start the instance again, it will stop after 1 minute which shows that the Lambda function is working.

Reflection and Critical Thinking

AWS Lambda is a service that be used to run a set of codes that are embedded in the trigger in response to an event that triggers it and it manages the compute resources too.

In this activity, I have learned how to create a Lambda function and link it to an EC2 instance. This lambda function would get triggered every time when the Instance is running for 1 minute and the action of the function causes the Instance to shut down.

Lambda can be configured with events that triggers it and makes it perform a scheduled task. They are stateless which means that they can easily scale when required. It can be written in JavaScript or Java.  We can use Lambda to track and audit the logs that are generated from S3, Kinesis, etc.  We can use Lambda to trigger when the object is being added to an S3 bucket.

 It can send logs to the CloudWatch for monitoring and alerting too which informs and helps the users and allows them to check the error/ problem and solve it. We can also set Lambda function for users whenever they are trying use the AWS resource and get it recorded so in case if the user tries to get past the security, the lambda will still notify the CloudWatch which would then alert the admin about it. This helps the admin to know who tried to get access to those resources.  We could also try to modify Lambda to create users and assign them to IAM. The downside of AWS Lambda is that it is only functional within the ecosystem of AWS.

Leave a comment

Design a site like this with WordPress.com
Get started