To be notified, schedule and configure Lambda

AWS Lambda is a feature-rich cloud computing service that allows you to automate your tasks in the age of continuous integration, Dev-ops, and deployment. Lambda, a compute service offered by Amazon Web Services, performs actions on AWS services based on the program code you upload. It can be triggered either by CloudWatch events or a scheduled event.
This blog will show you the step-by-step process.
Create Lambda Function
CloudWatch Integration of Lambda with CloudWatch (Scheduled event)
SNS Topic Creation and Subscriptions
CloudWatch Integration with SNS for Notification
Why use Lambda
Lambda is a great solution for events that need to be performed on a regular basis. It will also aid in infrastructure automation.
Examples of Use Cases
Regularly taking AMIs and Snapshots.
Add 2 servers at 8.00am if there are less than 30 servers.
Comparision of Costs
A dedicated Linux Cron machine can be used to schedule the running of a program that triggers API’s.
Even though the program is only used a few times per day, it must be run all year.
Cost of a (t1.micro-EC2 machine) running for a month = $14.64

Cost of running the same thing for a year =$ 14.64 x 12 = $ 175.56

Points to Ponder
You are responsible to your Linux Cron instance. You must take the necessary steps for Scaling and Patching, Administration, and Administration
Also, ensure that another machine is available to backup cron instances in case they go down.
Most of the time, if your Lambda function runs only for a few minutes, or a few times per day, it will be under the free Tier*.
Click the following link to find Lambda Pricing information and free tier information.
Creating Lambda Function
Step 1: Click Lambda in the AWS Dashboard to access the Lambda Console.
Step 2: Click on the Get Started Now button for a Lambda Function.

Step 3: There is a variety of Lambda Functions inbuilt that can be used. You can also specify the Language you wish to use. Click the Skip button at the bottom right corner if you wish to use your Lambda Function.

Step 4: Add the Name and Description you would like to provide to Lambda Function. You will need to choose the method you want to use your code. In this case, we will use the Edit code inline option. If you have dependencies in the program, you will need to use Upload a.Zip File or Upload a.Zip from Amazon S3.

Step 5: Select a Lambda role for authorization. This will perform the actions that you request via the code you provide. To allow Lambda to access SNS and CloudWatch, you must create a new role in IAM. If you need, select VPC. Click Next to create the Lambda Function.

Important Note:
CloudWatch and Lambda, while AWS Lambda can be used in different regions, are region-specific.
Make sure CloudWatch Rule and the Lambda Function are in the same area.
CloudWatch Integration of Lambda
Lambda is primarily Event-driven but Lambda can be Scheduled to occur at a specific time or interval of time.

Click Here to learn how to schedule an event.
Step 1: To configure, click on the CloudWatch Service icon from the AWS dashboard.

Step 2: Click on the Events Tab and click Create Rule to create an event.

Step 3: Click Schedule under the Select event source tab. The Event Selector is the source to invoke the target.

Step 4: Click on the Fixed Rate tab and then select Interval Period. It could be the frequency in minutes, hours or days. A Simple Cron Expression can also be specified. Click the Targets tab to add a target.
Click the following link to find out how to schedule an event according to a specific time.

Related Posts