How to Create Serverless Service with AWS Lambda and CloudWatch

This article shows how to create a Serverless Service using AWS Lambda and CloudWatch.

Select AWS Lambda and create a function

Click “Create function”

Define a function

In this example, Python was selected and a Function name was added.

Clicking “Create Function” will open Code source. Note that Basic Execution Rule will be enough for Permissions.

Create a lambda_function with desired logic

In this function, EC2 instances having a Tag ‘Test_StartEC2’ will be started.

Create a Rule in CloudWatch

Open CloudWatch service, select Rules under Events. Set a Cron expression to schedule to invoke the defined Lambda function.

In the right-hand side pane, enter Targets

Select “Configure Details”

Enter Name and Description of Rule, and Click “Create Rule”

Now a Cloud Watch Rule is created, and the EC2 instances will start at the scheduled time.

Leave a Comment