Answer - C.
The AWS Documentation mentions the following.
Option A is incorrect since there is no inbuilt scheduler in AWS Lambda.
Option B is incorrect since this would add more maintenance overhead.
Option D is incorrect since this service is an API monitoring service.
For more information on running Lambda functions on schedules, please refer to the below URL-
https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/RunLambdaSchedule.html
The correct answer is C. Use Cloudwatch events to schedule the Lambda function.
Explanation: AWS Lambda is a serverless compute service that allows developers to run their code without managing servers. Developers can create Lambda functions and trigger them using various events such as API Gateway, S3, and Cloudwatch events.
To run a Lambda function on a scheduled basis, we need to configure it to trigger at specific times. AWS provides various ways to schedule a Lambda function, such as:
A. Use the schedule service in AWS Lambda: AWS Lambda provides a built-in scheduler that allows developers to schedule a function to run at specific times. This option is ideal if the Lambda function needs to run at a fixed interval, for example, every 5 minutes, every hour, or every day. However, this option is limited to fixed schedules and cannot trigger a Lambda function based on more complex events.
B. Use an EC2 Instance to schedule the Lambda invocation: This option involves creating an EC2 instance and configuring it to run a script that invokes the Lambda function. This option is not ideal because it involves managing an EC2 instance and increases the infrastructure overhead.
C. Use Cloudwatch events to schedule the Lambda function: Cloudwatch events is a service that allows developers to create rules that match events and route them to targets such as Lambda functions. This option is ideal because Cloudwatch events can trigger Lambda functions based on complex event patterns, such as an S3 bucket upload or a Cloudtrail event.
D. Use Cloudtrail to schedule the Lambda function: Cloudtrail is a service that records API calls and events in AWS. This option is not ideal because Cloudtrail does not provide a mechanism to trigger Lambda functions directly. However, it can be used in conjunction with Cloudwatch events to trigger a Lambda function based on Cloudtrail events.
In summary, the ideal option to schedule a Lambda function is to use Cloudwatch events.